• 请问:如何在 ruby 代码中读取 yml 的内容?比如 yml 中 name 有:

    - WALKER
    - WALLACE
    - WALLY
    - WALTER
    - WALTON
    - WARD
    

    我想随机生成 100 个数据 并且数据名字是这里的:

    AML::load(File.read(Rails.root.to_s + '/config/users.yml'))
        ::Meter.create(:name=>)  #这里怎么写随机生成的100个数据  并且将名字塞进去??
    
  • Rails 5.2.2 jQuery 用不了? at 2019年03月14日

    改成

    require "/config/environment.rb"
    task :create_user do
      i = 1
      while i != 2
        ::User.create(:name=>"Cathy")
        ++ i
      end
    end
    
    task :create_comment do
    
    end
    
    

    还是会出现:

    C:\Users\ThinkPad\Desktop\Demo-test\rails>bundle exec rake create_user
    rake aborted!
    LoadError: cannot load such file -- /config/environment.rb
    C:/Users/ThinkPad/Desktop/Demo-test/rails/lib/tasks/user.rake:1:in `require'
    C:/Users/ThinkPad/Desktop/Demo-test/rails/lib/tasks/user.rake:1:in `<top (required)>'
    C:/Users/ThinkPad/Desktop/Demo-test/rails/Rakefile:6:in `<top (required)>'
    (See full trace by running task with --trace)
    
    
  • Rails 5.2.2 jQuery 用不了? at 2019年03月14日

    require './rails/app/models/user'

    task :create_user do i = 1 while i != 2 ::User.create(:name=>"Cathy") ++ i end end

    task :create_comment do

    end

    rake aborted!
    LoadError: cannot load such file -- ./rails/app/models/user
    C:/Users/ThinkPad/Desktop/Demo-test/rails/lib/tasks/user.rake:1:in `require'
    C:/Users/ThinkPad/Desktop/Demo-test/rails/lib/tasks/user.rake:1:in `<top (required)>'
    C:/Users/ThinkPad/Desktop/Demo-test/rails/Rakefile:6:in `<top (required)>'
    (See full trace by running task with --trace)
    
    

    请问这个咋回事?不好 i 意思 我这边没法发布