ruby-on-railsruby-on-rails-3simple-formrails-engines

Loading error for simple_form in Rails 3.2.8 engine


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?


Solution

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