user938363
user938363

Reputation: 10350

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?

Upvotes: 2

Views: 3441

Answers (2)

foureyedraven
foureyedraven

Reputation: 337

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.

Upvotes: 0

user938363
user938363

Reputation: 10350

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

Upvotes: 3

Related Questions