I have a Rails 3.1 application with assets set up to pre-compile in production (Heroku, in this case). This includes jQuery, jQueryUI and Mapstraction. Running heroku logs, however, reveals that Mapstraction, a mapping JS library, may not be pre-compiling successfully:
2012-10-25T05:13:11+00:00 app[web.1]: ActionView::Template::Error (mxn.js?(googlev3) isn't precompiled):
2012-10-25T05:13:11+00:00 app[web.1]: 8: <%= javascript_include_tag :application %>
2012-10-25T05:13:11+00:00 app[web.1]: 9: <%= csrf_meta_tag %>
2012-10-25T05:13:11+00:00 app[web.1]: 11: <%= javascript_include_tag "mxn.js?(googlev3)" %>
2012-10-25T05:13:11+00:00 app[web.1]: 12: <script type="text/javascript">
2012-10-25T05:13:11+00:00 app[web.1]: 10: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
I suspect that since Mapstraction (mxn.js) is being constructed with a geodata service provider name as a parameter that Rails might not be able to handle that. It works locally in a dev environment though, without precompiling. Any ideas on why precompiling would fail in this case?
You can manually include the necessary files to make Mapstraction work with the Rails asset pipeline:
curl https://raw.github.com/mapstraction/mxn/master/source/mxn.js > vendor/assets/javascripts/mxn.js
curl https://raw.github.com/mapstraction/mxn/master/source/mxn.core.js > vendor/assets/javascripts/mxn.core.js
curl https://raw.github.com/mapstraction/mxn/master/source/mxn.openlayers.core.js > vendor/assets/javascripts/mxn.openlayers.core.js
then you put
//= require mxn
//= require mxn.core
//= require mxn.openlayers.core
Related
I just installed passenger and I believe I got it working, but now my rails application seems to be unable to load cached assets. When attempting to load a page I get this message:
ActionView::Template::Error (No such file or directory - /home/glawson/vidStream/tmp/cache/assets/sprockets%2Ff1663d34d4b6003379113df98f1433a520130421-27670-18ux0pw.lock):
2: <html>
3: <head>
4: <title>VidStream</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8:
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___4187138815701226714_20468720'
This happens when I try to run my webapp with passenger or in development with rails server. I'm a little fuzzy on what the error even means other than it can't find a file that it's looking for.
In production mode you need to precompile the asset directory using
RAILS_ENV=production rake assets:precompile
Then only it will work. Because by default for prod asset precompile is enabled.
I successfully deployed my rails app to my VPS, but when I try to look at my server from browser, I get a 500 error ("We're sorry, but something's wrong"). The app is working fine locally, so I think the problem lies in not my code but somewhere else.
Here's the log from /current/log/production.log
ActionView::Template::Error (jquery.js isn't precompiled):
4: <title>Songhomme</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= javascript_include_tag 'jquery' %>
8: <%= csrf_meta_tags %>
9: </head>
10: <body>
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___2525571063257357898_28769560'
I also got the following error:
ActionView::Template::Error (/home/deployer/apps/songhomme/releases/20121204091428/app/views/posts/_posts.erb:27: syntax error, unexpected ',', expecting ')'
...ppend= ( link_to (t.name + " ", '/tags/' + t.id.to_s) );#out...
The code is working fine locally, so I'm not sure what's wrong with the second part of code. For the first part of code, does running rake assets:precompile before I push to my repo solve the problem?
I appreciate your help.
Try declaring your js includes in the manifest file application.js , not by javascript_include_tag. Since Rails version 3 this is the proper way . So , in your application.js :
//= require jquery
//= require jquery_ujs
I'm learning Rails and read about using CodeRay to have lovely syntax highlighting in your page. When I use rails server it's fine and everything is hunky dory, but when I try to deploy to Heroku I get the useful "something went wrong" page. According to the logs, ActionView::Template::Error (coderay.css isn't precompiled):. So I want to remove CodeRay from my Rails app for now.
I removed the CSS file, the link in the erb file, CodeRay from my Gemfile, ran bundle install and bundle update for good measure, but I still get the same error.
2012-05-27T07:41:22+00:00 app[web.1]: Completed 500 Internal Server Error in 98ms
2012-05-27T07:41:22+00:00 app[web.1]:
2012-05-27T07:41:22+00:00 app[web.1]: 2: <html>
2012-05-27T07:41:22+00:00 app[web.1]: 3: <head>
2012-05-27T07:41:22+00:00 app[web.1]: ActionView::Template::Error (coderay.css isn't precompiled):
2012-05-27T07:41:22+00:00 app[web.1]: 5: <%= stylesheet_link_tag "application", "coderay", :media => "all" %>
2012-05-27T07:41:22+00:00 app[web.1]: 4: <title>RG Simms</title>
2012-05-27T07:41:22+00:00 app[web.1]: 6: <%= javascript_include_tag "application" %>
2012-05-27T07:41:22+00:00 app[web.1]: 7: <%= csrf_meta_tags %>
2012-05-27T07:41:22+00:00 app[web.1]: 8: <link rel="/favicon.ico" alt="gentlemanraptor">
Now, this is really weird. I have removed the stylesheet_link_tag to coderay in the html.erb, uninstall the actual gem completely, and deployed to Heroku again, but with the same error.
Currently using the cedar stack and rails 3.2.3.
Am I doing something wrong?
You need to tell rails to precompile coderay.css along with your other assets:
# application.rb
config.precompile += %w(coderay.css)
Try that.
If it still doesn't work you probably need to remove the stylesheet link tag to coderay, since it will get bundled with your application.rb during asset precompilation
You need to compile your assets locally first.
Take a look here: https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar
Try the below before pushing to Heroku.
RAILS_ENV=production bundle exec rake assets:precompile
I'm stuck trying to get my app to work on heroku. I can run locally and it works well, but when I deploy to heroku I get the following error:
2012-05-18T21:26:18+00:00 app[web.1]: (in /app/app/assets/javascripts/application.js.erb)):
2012-05-18T21:26:18+00:00 app[web.1]: 8: <%= render 'layouts/shim'%>
2012-05-18T21:26:18+00:00 app[web.1]: ActionView::Template::Error (Unexpected character '#'
2012-05-18T21:26:18+00:00 app[web.1]: 4: <title><%= full_title(yield(:title))%></title>
2012-05-18T21:26:18+00:00 app[web.1]:
2012-05-18T21:26:18+00:00 app[web.1]: 5: <%= stylesheet_link_tag "application", :media => "all" %>
2012-05-18T21:26:18+00:00 app[web.1]: 7: <%= csrf_meta_tags %>
2012-05-18T21:26:18+00:00 app[web.1]: 3: <head>
2012-05-18T21:26:18+00:00 app[web.1]: 6: <%= javascript_include_tag "application" %>
2012-05-18T21:26:18+00:00 app[web.1]: app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___39687462904242755_48413880'
2012-05-18T21:26:18+00:00 app[web.1]:
2012-05-18T21:26:18+00:00 app[web.1]:
9: </head>
Initially I thought it was a coffeescript problem. But I have since gotten rid of any .coffee files just to see if it will work. Still, the same result
This is my application.js file:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_tree .
$(document).ready(function()
{
function setCountdownTimer(element, year, month, day) {
var date = new Date(year, month, day);
$(element).countdown({until: date});
}
$('#hashtag_id').live('change', function() {
$('#user_comments').empty();
$.ajax({ url: '/headlines/update_comments/',
data: {hashtag: this.value, id: $('#headline_tag').data('id')},
success: function(data) {
$('#user_comments').html(data);
}
})
});
});
Any ideas?
Have you changed any of the coffee script files to just js files, and left the comments at the top in:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
Remove these comments, if so.
This error occurs often in tandem with another asset pipeline error when Devise is installed. Before investigating the solutions stated here
rails 3.1.0 ActionView::Template::Error (application.css isn't precompiled)
try Snowangel's suggestion first to save time.
I am deploying a first rails app via capistrano with:
rails 3.1
passenger 3.0.11
nginx 1.0.10
The app errors out. In my $app/logs/production.log, I get:
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
8: <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.js"></script>
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__88091947956529734_37470040'
But in my application.rb, I have set:
# Enable the asset pipeline
config.assets.enabled = false
I thought this directive causes the asset pipeline to be disabled. Any ideas what is going on?
With the pipeline disabled, Rails is expecting the referenced files application.css and application.js to be available in the public directory at the pre-3.1 locations.
Is there a reason why you are not using the pipeline?