On Friday, July 12, 2013 2:07:55 AM UTC-4, farukhdm wrote:
>
> Following are the configurations in my production.rb file:
>
>   # Disable live compilation of assets(Don't fallback to assets pipeline 
> if a precompiled asset is missed)
>   config.assets.compile = false
>
>   # Assets pre-compilation task(rake assets:precompile) configurations
>   config.assets.css_compressor = :yui
>   config.assets.js_compressor    = :yui
>   config.assets.compress           = true
>
> Let me know, if these configs are specified correctly.
>
> On Friday, 12 July 2013 10:52:24 UTC+5:30, farukhdm wrote:
>>
>> Thanks for the update.
>>
>> jquery.bxslider.min.js in my case is not part of application.js
>>
>> I have added jquery.bxslider.min.js to pre-compile path also, so that it 
>> can be loaded independently.
>> Its available in public/assets folder too.
>>
>> You said "I'm not surprised it is re-compiling the source code at 
>> runtime."..I totally agree.
>> However that should happen when browser request that very particular 
>> asset, not while creating page response that has
>>
>> <script src="jquery.bxslider.min.js"></script>
>>
>> in the markup.
>>
>> Am I going astray here in making you understand the issue.
>> Let me know.
>>
>>
>> On Thursday, 11 July 2013 21:58:03 UTC+5:30, mike wrote:
>>>
>>>
>>>
>>> On Thursday, July 11, 2013 7:24:34 AM UTC-4, farukhdm wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am stuck in a weird situation where in my production environment, an 
>>>> asset is being attempted to compress while rendering a view.
>>>> I've all my assets put into public/assets folder via rake 
>>>> "assets:precompile"
>>>>
>>>> production.rb has following configurations:
>>>> --------------------------------------------------------------
>>>>  # Disable live compilation of assets(Don't fallback to assets pipeline 
>>>> if a precompiled asset is missed)
>>>>   config.assets.compile = false
>>>>
>>>>   # Assets pre-compilation task(rake assets:precompile) configurations
>>>>   config.assets.css_compressor = :yui
>>>>   config.assets.js_compressor  = :yui
>>>>   config.assets.compress       = true
>>>>
>>>>
>>>> When I request for some page let say  http://www.example.com/home, 
>>>> while generating the page response, Rails is trying to compress an asset 
>>>> named 
>>>> "jquery.bxslider.min"
>>>>
>>>> I've following code that is creating error.
>>>>
>>>> <%= content_for :js_include do %>
>>>>   <%= javascript_include_tag 'jquery.bxslider.min' %>
>>>> <% end %>
>>>>
>>>> Error in log:
>>>> =============
>>>> ActionView::Template::Error (undefined method `exitstatus' for nil:NilClass
>>>>   (in /example/lib/assets/javascripts/jquery.bxslider.min.js)):
>>>>     57: <%= content_for :js_include do %>
>>>>     58:   <%= javascript_include_tag 'jquery.bxslider.min' %>
>>>>     59: <% end %>
>>>>
>>>>
>>>> The error is however for missing java(as I'm using YUI for compression, 
>>>> which depends on java)
>>>>
>>>> I don't want any live compression & compilation, as assets are already 
>>>> available in public/assets folder
>>>>
>>>>
>>>> I am surprised, why Rails is trying to compress asset while rendering an 
>>>> action.  
>>>>
>>>>
>>>> Please advise.
>>>>
>>>>
>>>> Regards
>>>>
>>>> Farukh D M
>>>>
>>>
>>> I'm not surprised it is re-compiling the source code at runtime.  You 
>>> have to be careful with javascript_include_tag when you are using the asset 
>>> pipeline.  When you precompile your assets, everything is put into one js 
>>> file with a long, cryptic name that looks something like the following in 
>>> html:
>>>
>>> <script 
>>> src="/assets/application-931a21730f0f60d50be598cdd891dccf.js"></script>
>>>
>>> When you then insert a javascript tag, it's going to look like the 
>>> following in your html:
>>>
>>> <script src="jquery.bxslider.min.js"></script>
>>>
>>> The browser is going to attempt to load both files.  It doesn't detect 
>>> that the contents of jquery.bxslider.min.js are actually already in the 
>>> first file.  Because this file is located in the /app/assets/js directory, 
>>> it's going to be processed by rails through the asset compiler when the 
>>> browser requests the file.
>>>
>>> You shouldn't reference a javascript file in a script tag if you've 
>>> already included it in the asset pipeline unless you truly intend to load 
>>> it twice.
>>>
>>> If you have javascript you want to load independent of the asset 
>>> pipeline and you don't want it processed through the asset compiler, you 
>>> should reference it in a javascript_include_tag as you have done above, but 
>>> you should locate the file in the public/js directory.
>>>
>>>
>>>
>>>  
>>>
>>
You're right, I didn't fully understand the issue.  The settings in your 
production.rb are typical production settings.  However, in this case, the 
first setting, config.assets.compile = false has implications.

When this is set to false, the system assumes all assets have been 
pre-compiled.  When you pre-compile, a manifest is generated that maps the 
"normal" file names to the cryptic filename it's now compressed into.  When 
html code is generated from a view, it references the manifest, and 
substitutes the cryptic filename.  

This is the point where I'm unsure of what happens.  In your case, there's 
a file referenced in the assets directory that isn't in the manifest and 
isn't pre-compiled.  I'm not sure what the system does because when this 
flag is set to false, it doesn't even load the pipeline gems so it doesn't 
have access to the compiler.  I'm guessing it throws an error, but that's a 
guess, which would be the error you encountered.

I'd have to test this but my guess is that you either need to pre-compile 
the asset, or locate it in the public directory (only) and write the tag to 
access the file in the public directory.

I'm not sure this is correct, but hopefully it will point you in the right 
direction.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1b9f25e0-7381-4d41-8353-e0ccb3eb37d1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to