Loading error for simple_form in rails 3.2.8 engine

邮差的信 提交于 2019-12-08 04:25:35

问题


When loading simple_form in our rails 3.2.8 engine, the simple_form initializer file simple_form.rb causes error:

/config/initializers/simple_form.rb:2:in `<top (required)>': uninitialized constant SimpleForm (NameError)
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'

Under engine's config/initializers, the simple_form.rb is:

# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
  # Wrappers are used by the form builder to generate a
  # complete input. You can remove any component from the

The SimpleForm.setup do |config| causes the error. tried to add engine namespece as RfqxEmc::SimpleForm.setup do |config| and the error is the same.

What's the right way to install/load simple_form in rails engine? Thanks for help.


回答1:


Here is the post talking about simple_form for rails engine. Just add require 'simple_form' in simple_form.rb.




回答2:


If the accepted answer doesn't work and you're creating an engine, I had to install the gem in my application as well. I'm too green to know if there's a way to inherit gems from an engine in an easier way. Requiring 'simple_form' in the config/application.rb didn't work, nor did I need to require simple_form in my initializers.



来源:https://stackoverflow.com/questions/13633195/loading-error-for-simple-form-in-rails-3-2-8-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!