I have a rails 3.2 app, and it is giving me the ol' 'We're sorry but something went wrong.' message when I deploy to heroku. A check of the logs has
2013-11-13T17:27:25.599927+00:00 app[web.1]: Started GET "/" for 54.247.188.179 at 2013-11-13 17:26:25 +0000
2013-11-13T17:27:25.599927+00:00 app[web.1]:
2013-11-13T17:27:25.599234+00:00 app[web.1]: Rendered static_pages/root.html.erb within layouts/application (5.9ms)
2013-11-13T17:27:25.599506+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2013-11-13T17:27:25.600076+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2013-11-13T17:27:25.600076+00:00 app[web.1]: Rendered static_pages/root.html.erb within layouts/application (6.1ms)
2013-11-13T17:27:25.600076+00:00 app[web.1]: 10:
2013-11-13T17:27:25.600076+00:00 app[web.1]: ActionView::Template::Error (static_pages.css isn't precompiled):
2013-11-13T17:27:25.600076+00:00 app[web.1]: 9:
Along with some other stuff that looks very similar. I have been working on this for quite a bit and seen some other similar questions, so I'll head off some potential problems you think I might have:
I have no public/assets folder on my local before pushing to heroku
I have the line config.assets.enabled = true in my application.rb
I have the line config.assets.initialize_on_precompile = false in my application.rb
Thanks in advance, happy to supply more info.
Resolved
Apparently in order to get that css to compile correctly I had to add this line to config/environments/production.rb:
config.assets.enabled = true
Thanks to Tyler for that one.
Looks like you're not precompiling static_pages.css. I don't know if that's intentional, but you have 2 options:
Option 1: Avoid fallback to the assets pipeline if a precompiled asset is missed. You can do so by setting:
# config/environments/production.rb
config.assets.compile = true
This will cause rails to compile your uncompiled file on the fly, rather than throwing an error (which it is doing now). More on this setting here: config.assets.compile=true in Rails production, why not?
Option 2: Make sure the file is being precompiled. You can do so by setting:
# config/environments/production.rb
config.assets.precompile += ['admin.js', 'admin.css', 'static_pages.css']
This will cause rails to precompile and include the stylesheet in your asset pipeline. More on this setting here: What is the purpose of config.assets.precompile?
You need to build a list of assets to be precompiled.
For example, in your config/environments/production.rb:
config.assets.precompile += %w( foo.js foo.scss static_pages.css)
Related
My development and test servers are working fine, but I am having trouble with the production server. Sequence:
RAILS_ENV=production bundle exec rake assets:precompile
sudo httpd service restart
When I try to go to my production server from a browser, I get the dreaded:
We're sorry, but something went wrong
Looking at production.log, I see:
ActionView::Template::Error (statics.css isn't precompiled)
So, I added the following to config/application.rb:
config.assets.precompile += ['statics.css']
Still got the error screen, now the production log says:
ActionView::Template::Error (statics.js isn't precompiled)
So, I added the following to config/application.rb:
config.assets.precompile += ['statics.js']
I precompiled assets and restarted the server, but I'm still getting the same error message:
ActionView::Template::Error (statics.js isn't precompiled)
I also tried the following:
config.assets.precompile += %w( *.css *.js )
config.assets.precompile += ('*.css','*.js')
config.assets.precompile += ('.css','.js')
but I keep getting the error:
ActionView::Template::Error (statics.js isn't precompiled)
These are all suggestions I found on stackoverflow. Any ideas?
This fixed the issue for me: Go to config/environments/production.rb and set config.assets.compile = true.
I have troubles with wicked_pdf on production server. I have such code here in _results.pdf.haml:
#container
= wicked_pdf_javascript_include_tag "pdf_application"
:javascript
$(document).ready(function(){drawPDFCharts(#{generate_javascript_for_pdf_generator(#poll.answer_count_per_question)}, "container")});
here is pdf_application.js
//= require jquery
//= require highcharts
//= require poll-pdf-chart-generation.js.coffee
On local machine and staging everithing just fine, but on production there is an error:
Started GET "/121-consumer-electronics.pdf" for 94.76.74.170 at 2013-01-16 13:52:53 +0000
Processing by PollsController#show as PDF
Parameters: {"id"=>"121-consumer-electronics"}
***************WICKED***************
Rendered polls/_results.pdf.haml (145.7ms)
Completed 500 Internal Server Error in 816ms
ActionView::Template::Error (pdf_application.js isn't precompiled):
8:
9: #container
10:
11: = wicked_pdf_javascript_include_tag "pdf_application"
12: :javascript
13: $(document).ready(function(){drawPDFCharts(#{generate_javascript_for_pdf_generator(#poll.answer_count_per_question)}, "container")});
Here is my production.rb:
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
I cant figure out how to make it work, I saw some similar questions here, And I tried to add this file to precompile array and restart the server, but it didnt help. As I get I have compiling assets on local machine, and no compiling on production, and somehow this file is not precompiled when I try to run it...
Which file contains the javascript code that you would like to use? Is it poll-pdf-chart-generation.js.coffee?
I am unsure if wicked pdf can use coffee files but someone can please correct me if I am wrong.
I believe a workaround solution is to try converting poll-pdf-chart-generation.js.coffee to a js file and adding it to production.rb:
config.assets.precompile += ['poll-pdf-chart-generation.js']
Reference: Rails guide on asset pipeline
Change your wickedpdf include tag to look at the precompiled js asset:
wicked_pdf_javascript_include_tag "poll-pdf-chart-generation"
And you will also need to precompile your assets:
bundle exec rake assets:precompile
Sounds like the .js file was changed and not recompiled. Rails 3 compiles js, css, and stylesheets into a single file to be sent once to the browser. If anything in the assets directory changes, the whole thing has to be recompiled. Try
bundle exec rake assets:precompile
Good luck
Bob
I get this error when i try to deploy my app to Heroku. My first deployment works fine before I'm doing heroku run rake db:reset.
After this, I have errors below: "We're sorry, but something went wrong." and "The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved."
My heroku logs says:
2012-12-08T11:40:54+00:00 app[web.1]: ActionView::Template::Error (bootstrap.css isn't precompiled):
2012-12-08T11:40:54+00:00 app[web.1]: 9: <%= csrf_meta_tags %>
2012-12-08T11:40:54+00:00 app[web.1]:
2012-12-08T11:40:54+00:00 app[web.1]: 8: <%= javascript_include_tag "bootstrap", media: "all"%>
Some one, Can you help me ?
Looks like Heroku is complaining that your assets are not precompiled. I'd read through this tutorial about rails on heroku, there is a section dedicated to resource pre-compilation.
You can tell your application to precompile assets in production
#config/environments/production.rb
config.assets.compile = true
# Heroku also requires this to be false
config.assets.initialize_on_precompile=false
Or you can precompile your assets using the rake task
#before pushing to Heroku and then you can push
rake assets:precompile
#or after you've pushed to heroku
heroku run rake assets:precompile
I'm using Rails on Heroku Cedar stack and it's not throwing any issues while compiling the assets but then I get a 500 internal server error:
2012-06-25T23:22:59+00:00 app[web.1]: ActionView::Template::Error (bootstrap-datepicker.js isn't precompiled):
Any idea what might be causing this? This is the javascript file I'm including (except I downloaded it locally) https://github.com/eternicode/bootstrap-datepicker/blob/master/js/bootstrap-datepicker.js
I'm including it in my application.html.erb like so:
<%= javascript_include_tag "bootstrap-datepicker" %>
Is it because its not a coffeescript file? Any help is appreciated!
I figured it out. I had to add it to production.rb in config.assets.precompile
In production.rb I added it to my config.assets.precompile:
config.assets.precompile += %w( jquery.dataTables.min.js jquery-ui-1.8.21.custom.min.js jquery-ui-1.8.21.custom.css bootstrap-datepicker.js fullcalendar.js)
I've just migrated to rails 3.1 and I'm having trouble getting started with the asset pipeline.
I ran: bundle exec rake assets:precompile RAILS_ENV=production after adding additional css files into config.assets.precompile += ['scaffold.css', 'other.css', 'other.js'] all of my files are located in the /app/asset images, javascripts, or stylesheets path.
Following the rake task, I can see the manifest.yml file but it is missing the additional css and js files I added to the config.assets.precompile
Here is my manifest.yml file that lives on prod:
connect.gif: connect-b85d46914c10cb653f3444c3529b83eb.gif connect.png:
connect-bce549a396f27cc5f7b315190ee3385a.png d.jpeg:
d-c5f2ca3025794efdc341159538f4a0bf.jpeg data.png:
data-d225a9937a1aa78805e704ada167b2d0.png fb.png:
fb-2e743f3607323f9d21dd2e96b5c95d4b.png feed.png:
feed-fd4c0dc513639edd0ba2f39a063fdc90.png grid.png:
grid-b3db76abb46477b06c15055df8412c79.png i.png:
i-5ac52498083d9dfc5f898cdf666bc9c0.png infb.png:
infb-80208a4e1bd3d2a03f23097a7d19fe7e.png r.png:
r-ba27ded8b8873c851cd9aaf8697f8092.png rails.png:
rails-e4b51606cd77fda2615e7439907bfc92.png share.jpeg:
share-47877a532c58510f38eeb534122b4846.jpeg share.png:
share-b9939bdcdf8b082eeb27697592258b9a.png signup.jpeg:
signup-23dfea4e8af95dae93ab254162e01fc2.jpeg tc.png:
tc-abb1838a7396c3a0a54e68ecb80cd225.png tweet.png:
tweet-3865676af138fa7d80e0e416210f2fa0.png yellow.png:
yellow-b2257e0f9bb17cd4b44faaee30df8fa6.png jquery.flot.js:
jquery.flot-944582c3d888856c9d82964ea8cf0bcc.js jquery-ui.min.js:
jquery-ui.min-4258e47b40673a02bedfda178628bfba.js jquery.min.js:
jquery.min-17322428695737103f15e8b9db8b5909.js application.js:
application-f71535809bb0483163e3e4d857abe6d0.js
What is going on here? I've restarted both passenger with touch restart.txt and nginx. I've read all of the documentation on this issue.
nginx error.log:
cache: [GET /] miss
ActionView::Template::Error (scaffold.css isn't precompiled):
2: %html
3: %head
4: %title redmeetsblue
5:
6: = javascript_include_tag "application.js"
7: = csrf_meta_tag
8: %script{:src => "http://connect.facebook.net/en_US/all.js#appId=143150285757259&xfbml=1"}
app/views/layouts/application.html.haml:5:in `_app_views_layouts_application_html_haml__44133251_81438200'
app/controllers/homes_controller.rb:7:in `index'
Have you set the config.assets.precompile values in application.rb ? If you set them elsewhere they won't be picked up when you precompile.