Christiaan Van den Poel
2010-Sep-09 21:01 UTC
Rails3: jquery-rails gem sets ''config.action_view.javascript_expansions'' but cannot be overriden in ''config/application.rb''
Hello,
I''ve created a new Rails3 app and I''m using jQuery instead of
prototype.
Gemfile:
gem ''jquery-rails''
in my config/application.rb I want do the following:
config/application.rb
if Rails.env.production?
config.action_view.javascript_expansions[:defaults] = %w(jquery.min
rails application)
else
config.action_view.javascript_expansions[:defaults] = %w(jquery rails
application)
end
So in production I want to include jquery.min whereas in development I want
the unminified (jquery).
But this seems not to work and when I look at the jquery-rails railtie, I
see the following code:
module Jquery
module Rails
class Railtie < ::Rails::Railtie
config.before_initialize do
if
::Rails.root.join("public/javascripts/jquery-ui.min.js").exist?
config.action_view.javascript_expansions[:defaults] %w(jquery.min
jquery-ui.min rails)
else
config.action_view.javascript_expansions[:defaults] %w(jquery.min
rails)
end
end
end
end
end
This sets the config.action_view.javascript_expansions[:defaults] to
always use jquery.min. So it seems to me that the code from my app
(config/application.rb) isn''t applied. Although this should be
possible to do.
Is this expected behavior? Shouldn''t it be possible to override the
expansions in your own application?
TIA
C+++
--
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.
Teng Siong Ong
2010-Sep-10 07:11 UTC
Re: Rails3: jquery-rails gem sets ''config.action_view.javascript_expansions'' but cannot be overriden in ''config/application.rb''
you don''t actually need the "jquery-rails" gem. you might have to report to the gem''s author about this. : ) so, basically, you should be fine once you remove the "jquery-rails" gem from your Gemfile. On Thu, Sep 9, 2010 at 4:01 PM, Christiaan Van den Poel < christiaan.vandenpoel@gmail.com> wrote:> Hello, > > I''ve created a new Rails3 app and I''m using jQuery instead of prototype. > > Gemfile: > gem ''jquery-rails'' > > in my config/application.rb I want do the following: > > config/application.rb > if Rails.env.production? > config.action_view.javascript_expansions[:defaults] = %w(jquery.min > rails application) > else > config.action_view.javascript_expansions[:defaults] = %w(jquery rails > application) > end > > So in production I want to include jquery.min whereas in development I want > the unminified (jquery). > > But this seems not to work and when I look at the jquery-rails railtie, I > see the following code: > > module Jquery > > > > module Rails > > > > class Railtie < ::Rails::Railtie > > > > config.before_initialize do > > > > if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist? > > > > config.action_view.javascript_expansions[:defaults] = %w(jquery.min jquery-ui.min rails) > > > > else > > > > config.action_view.javascript_expansions[:defaults] = %w(jquery.min rails) > > > > end > > > > end > > > > end > > > > end > > > > end > > > > > This sets the config.action_view.javascript_expansions[:defaults] to always use jquery.min. So it seems to me that the code from my app (config/application.rb) isn''t applied. Although this should be possible to do. > > > > > Is this expected behavior? Shouldn''t it be possible to override the expansions in your own application? > > > > > TIA > > > > > C+++ > > > > -- > 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<rubyonrails-core%2Bunsubscribe@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.
Christiaan Van den Poel
2010-Sep-10 07:35 UTC
Re: Rails3: jquery-rails gem sets ''config.action_view.javascript_expansions'' but cannot be overriden in ''config/application.rb''
True but I was wondering why it didn''t work.
In the jquery-rails (which is actually a railtie) there is the code:
config.before_initialize do ...
<set expansions>
end
So this could mean that during initialisation (in your
config/application.rb) you could easily change this yourself but as it is
now, it doesn''t work.
So I was wondering whether this is expected behavior or not.
C+++
On Fri, Sep 10, 2010 at 9:11 AM, Teng Siong Ong <siong1987@gmail.com>
wrote:
> you don''t actually need the "jquery-rails" gem. you
might have to report to
> the gem''s author about this. : )
>
> so, basically, you should be fine once you remove the
"jquery-rails" gem
> from your Gemfile.
>
> On Thu, Sep 9, 2010 at 4:01 PM, Christiaan Van den Poel <
> christiaan.vandenpoel@gmail.com> wrote:
>
>> Hello,
>>
>> I''ve created a new Rails3 app and I''m using jQuery
instead of prototype.
>>
>> Gemfile:
>> gem ''jquery-rails''
>>
>> in my config/application.rb I want do the following:
>>
>> config/application.rb
>> if Rails.env.production?
>> config.action_view.javascript_expansions[:defaults] =
%w(jquery.min
>> rails application)
>> else
>> config.action_view.javascript_expansions[:defaults] = %w(jquery
rails
>> application)
>> end
>>
>> So in production I want to include jquery.min whereas in development I
>> want the unminified (jquery).
>>
>> But this seems not to work and when I look at the jquery-rails railtie,
I
>> see the following code:
>>
>> module Jquery
>>
>>
>>
>>
>> module Rails
>>
>>
>>
>>
>> class Railtie < ::Rails::Railtie
>>
>>
>>
>>
>> config.before_initialize do
>>
>>
>>
>>
>> if
::Rails.root.join("public/javascripts/jquery-ui.min.js").exist?
>>
>>
>>
>>
>> config.action_view.javascript_expansions[:defaults] =
%w(jquery.min jquery-ui.min rails)
>>
>>
>>
>>
>> else
>>
>>
>>
>>
>> config.action_view.javascript_expansions[:defaults] =
%w(jquery.min rails)
>>
>>
>>
>>
>> end
>>
>>
>>
>>
>> end
>>
>>
>>
>>
>> end
>>
>>
>>
>>
>> end
>>
>>
>>
>>
>> end
>>
>>
>>
>>
>>
>> This sets the config.action_view.javascript_expansions[:defaults] to
always use jquery.min. So it seems to me that the code from my app
(config/application.rb) isn''t applied. Although this should be possible
to do.
>>
>>
>>
>>
>>
>> Is this expected behavior? Shouldn''t it be possible to
override the expansions in your own application?
>>
>>
>>
>>
>>
>> TIA
>>
>>
>>
>>
>>
>> C+++
>>
>>
>>
>>
>> --
>> 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<rubyonrails-core%2Bunsubscribe@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<rubyonrails-core%2Bunsubscribe@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.
Teng Siong Ong
2010-Sep-10 13:25 UTC
Re: Rails3: jquery-rails gem sets ''config.action_view.javascript_expansions'' but cannot be overriden in ''config/application.rb''
http://www.railsdispatch.com/posts/how-rails-3-enables-more-choices-part-1 check out the article. it actually explains the flow how gem gets loaded with hooks. maybe you should try "before_configuration" instead. On Fri, Sep 10, 2010 at 2:35 AM, Christiaan Van den Poel < christiaan.vandenpoel@gmail.com> wrote:> True but I was wondering why it didn''t work. > > In the jquery-rails (which is actually a railtie) there is the code: > > config.before_initialize do ... > <set expansions> > end > > So this could mean that during initialisation (in your > config/application.rb) you could easily change this yourself but as it is > now, it doesn''t work. > > So I was wondering whether this is expected behavior or not. > > C+++ > > > On Fri, Sep 10, 2010 at 9:11 AM, Teng Siong Ong <siong1987@gmail.com>wrote: > >> you don''t actually need the "jquery-rails" gem. you might have to report >> to the gem''s author about this. : ) >> >> so, basically, you should be fine once you remove the "jquery-rails" gem >> from your Gemfile. >> >> On Thu, Sep 9, 2010 at 4:01 PM, Christiaan Van den Poel < >> christiaan.vandenpoel@gmail.com> wrote: >> >>> Hello, >>> >>> I''ve created a new Rails3 app and I''m using jQuery instead of prototype. >>> >>> Gemfile: >>> gem ''jquery-rails'' >>> >>> in my config/application.rb I want do the following: >>> >>> config/application.rb >>> if Rails.env.production? >>> config.action_view.javascript_expansions[:defaults] = %w(jquery.min >>> rails application) >>> else >>> config.action_view.javascript_expansions[:defaults] = %w(jquery >>> rails application) >>> end >>> >>> So in production I want to include jquery.min whereas in development I >>> want the unminified (jquery). >>> >>> But this seems not to work and when I look at the jquery-rails railtie, I >>> see the following code: >>> >>> module Jquery >>> >>> >>> >>> >>> >>> >>> module Rails >>> >>> >>> >>> >>> >>> >>> class Railtie < ::Rails::Railtie >>> >>> >>> >>> >>> >>> >>> config.before_initialize do >>> >>> >>> >>> >>> >>> >>> if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist? >>> >>> >>> >>> >>> >>> >>> config.action_view.javascript_expansions[:defaults] = %w(jquery.min jquery-ui.min rails) >>> >>> >>> >>> >>> >>> >>> else >>> >>> >>> >>> >>> >>> >>> config.action_view.javascript_expansions[:defaults] = %w(jquery.min rails) >>> >>> >>> >>> >>> >>> >>> end >>> >>> >>> >>> >>> >>> >>> end >>> >>> >>> >>> >>> >>> >>> end >>> >>> >>> >>> >>> >>> >>> end >>> >>> >>> >>> >>> >>> >>> end >>> >>> >>> >>> >>> >>> >>> >>> This sets the config.action_view.javascript_expansions[:defaults] to always use jquery.min. So it seems to me that the code from my app (config/application.rb) isn''t applied. Although this should be possible to do. >>> >>> >>> >>> >>> >>> >>> >>> Is this expected behavior? Shouldn''t it be possible to override the expansions in your own application? >>> >>> >>> >>> >>> >>> >>> >>> TIA >>> >>> >>> >>> >>> >>> >>> >>> C+++ >>> >>> >>> >>> >>> >>> >>> -- >>> 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<rubyonrails-core%2Bunsubscribe@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<rubyonrails-core%2Bunsubscribe@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<rubyonrails-core%2Bunsubscribe@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.