Rodrigo Rosenfeld Rosas
2012-Jul-15 12:13 UTC
Why do I need to require my gem in application.rb so that I can use its settings in production?
I''ve released a new Engine yesterday, called oojspec: https://github.com/rosenfeld/oojspec It is a testing framework similar to Jasmine.js and Buster.js and it is integrated to the Rails asset pipeline. The problem is that I don''t understand why I need this line in my example application hosted on Heroku: https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L18 I need `require "oojspec"` just before using the setting declared by the gem: https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L70 And the require is needed only when running under production environment. This is not a major problem for oojspec itself since it is not meant to be run under production but by a rake task instead (rake sandbox_assets:serve). But I became curious. Why isn''t Bundler automatically requiring my gems before the block in application.rb? Is there something I could do from the engine gem to expose the option to application.rb without requiring the gem to be explicitly loaded before the block? Thanks in advance, Rodrigo. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Allen Madsen
2012-Jul-15 12:57 UTC
Re: Why do I need to require my gem in application.rb so that I can use its settings in production?
You''d want to move your gem out of assets if you want it to be available in other environments on heroku. Allen Madsen http://www.allenmadsen.com On Sun, Jul 15, 2012 at 8:13 AM, Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com> wrote:> I''ve released a new Engine yesterday, called oojspec: > > https://github.com/rosenfeld/oojspec > > It is a testing framework similar to Jasmine.js and Buster.js and it is > integrated to the Rails asset pipeline. > > The problem is that I don''t understand why I need this line in my example > application hosted on Heroku: > > > https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L18 > > I need `require "oojspec"` just before using the setting declared by the > gem: > > > https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L70 > > And the require is needed only when running under production environment. > > This is not a major problem for oojspec itself since it is not meant to be > run under production but by a rake task instead (rake sandbox_assets:serve). > > But I became curious. Why isn''t Bundler automatically requiring my gems > before the block in application.rb? > > Is there something I could do from the engine gem to expose the option to > application.rb without requiring the gem to be explicitly loaded before the > block? > > Thanks in advance, > Rodrigo. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Allen Madsen
2012-Jul-15 12:58 UTC
Re: Why do I need to require my gem in application.rb so that I can use its settings in production?
These comments in your gemfile explain why: https://github.com/rosenfeld/oojspec-test/blob/master/Gemfile#L10:L11 Allen Madsen http://www.allenmadsen.com On Sun, Jul 15, 2012 at 8:57 AM, Allen Madsen <allen.c.madsen@gmail.com>wrote:> You''d want to move your gem out of assets if you want it to be available > in other environments on heroku. > > Allen Madsen > http://www.allenmadsen.com > > > > On Sun, Jul 15, 2012 at 8:13 AM, Rodrigo Rosenfeld Rosas < > rr.rosas@gmail.com> wrote: > >> I''ve released a new Engine yesterday, called oojspec: >> >> https://github.com/rosenfeld/oojspec >> >> It is a testing framework similar to Jasmine.js and Buster.js and it is >> integrated to the Rails asset pipeline. >> >> The problem is that I don''t understand why I need this line in my example >> application hosted on Heroku: >> >> >> https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L18 >> >> I need `require "oojspec"` just before using the setting declared by the >> gem: >> >> >> https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L70 >> >> And the require is needed only when running under production environment. >> >> This is not a major problem for oojspec itself since it is not meant to >> be run under production but by a rake task instead (rake >> sandbox_assets:serve). >> >> But I became curious. Why isn''t Bundler automatically requiring my gems >> before the block in application.rb? >> >> Is there something I could do from the engine gem to expose the option to >> application.rb without requiring the gem to be explicitly loaded before the >> block? >> >> Thanks in advance, >> Rodrigo. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> To unsubscribe from this group, send email to >> rubyonrails-core+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-core?hl=en. >> > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Rodrigo Rosenfeld Rosas
2012-Jul-15 14:42 UTC
Re: Why do I need to require my gem in application.rb so that I can use its settings in production?
Thank you, Allen! That makes sense. I''ve already extracted it out of the assets group. Cheers, Rodrigo. Em 15-07-2012 09:58, Allen Madsen escreveu:> These comments in your gemfile explain why: > https://github.com/rosenfeld/oojspec-test/blob/master/Gemfile#L10:L11 > > Allen Madsen > http://www.allenmadsen.com > > > On Sun, Jul 15, 2012 at 8:57 AM, Allen Madsen > <allen.c.madsen@gmail.com <mailto:allen.c.madsen@gmail.com>> wrote: > > You''d want to move your gem out of assets if you want it to be > available in other environments on heroku. > > Allen Madsen > http://www.allenmadsen.com > > > > On Sun, Jul 15, 2012 at 8:13 AM, Rodrigo Rosenfeld Rosas > <rr.rosas@gmail.com <mailto:rr.rosas@gmail.com>> wrote: > > I''ve released a new Engine yesterday, called oojspec: > > https://github.com/rosenfeld/oojspec > > It is a testing framework similar to Jasmine.js and Buster.js > and it is integrated to the Rails asset pipeline. > > The problem is that I don''t understand why I need this line in > my example application hosted on Heroku: > > https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L18 > > I need `require "oojspec"` just before using the setting > declared by the gem: > > https://github.com/rosenfeld/oojspec-test/blob/master/config/application.rb#L70 > > And the require is needed only when running under production > environment. > > This is not a major problem for oojspec itself since it is not > meant to be run under production but by a rake task instead > (rake sandbox_assets:serve). > > But I became curious. Why isn''t Bundler automatically > requiring my gems before the block in application.rb? > > Is there something I could do from the engine gem to expose > the option to application.rb without requiring the gem to be > explicitly loaded before the block? > > Thanks in advance, > Rodrigo. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.