我尝试了命令: rails generate simple_form:install
而且 - 它没有运行。相反,输出看起来像是我给 rails 一个格式错误的命令行,它返回了一个使用文件的副本。
然后,在 RubyMine 中,我再次尝试了 - 这次得到了错误回溯 - 第一行如下所示:
/home/user1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/generators/base.rb:265:in `const_defined?': wrong constant name SimpleForm:installGenerator
注释掉 base.rb 中的第 265-269 行后:
# if last && last.const_defined?(last_name.camelize, false)
# raise Error, "The name '#{class_name}' is either already used in your application " <<
# "or reserved by Ruby on Rails. Please choose an alternative and run " <<
# "this generator again."
# end
再次运行命令,我得到:
/home/user1/.rvm/rubies/ruby-2.0.0-p247/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/user1/RubymineProjects/TravelAid/bin/rails generate generator simple_form:install -s
create lib/generators/simple_form:install
create lib/generators/simple_form:install/simple_form:install_generator.rb
create lib/generators/simple_form:install/USAGE
create lib/generators/simple_form:install/templates
Process finished with exit code 0
这看起来不错,但我还没有回去检查 simple_form 是否有效。
在 lib/generators 下,我有:
simple_form
templates
simple_form_generator.rb
USAGE
simple_form.install
templates
simple_form.install_generator.rb (created about 18 minutes ago - consistent with new)
USAGE
我在 Rubymine 中运行 Rails 4.0.0 和 ruby-2.0.0-p247