I'm using Rails 3.0.10 and running rake assets precompile at production server and facing problem as manifest requires output filename.this code is already deployed on heroku server and working fine. Please provide a solution on this.
Related
I've build a simple website, using Rails so I can deploy it to Heroku. It runs perfectly locally, everything works fine. It deploys fine to Heroku but when opening the webpage (http://a-clean.herokuapp.com/) I get the following error displayed:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
When I check the logs (running heroku logs in terminal) it shows the error:
ActionView::Template::Error (The asset "a_clean_sample_1.jpg" is not present in the asset pipeline.)
So far this is just a one-page website with a couple of partials. Here is the github repository: https://github.com/webbc99/a-clean
The image it's failing on is loaded in app/views/welcome/home.html.erb line 57.
Rails version 5.1.6, Ruby version 2.5.0
I've double checked that the images are in fact in the app/assets/images folder, and the image_tags are using the file extensions.
I've tried running heroku run rake assets:precompile, and I've tried using the rails12factor gem and also without it. I have tried changing config.assets.compile = false to true in the config/environments/production.rb which did get the page to load but all of the images were ignoring styling and were huge.
What is really confusing me is that I have deployed several other rails apps, same rails version, same ruby version, and none of these have had this issue before.
Here is a working app:
https://github.com/webbc99/presumptuous
https://presumptuous.herokuapp.com/
Any help would be greatly appreciated, been googling this for hours with no luck.
It's the simplest way to fix this problem is; You need to run as follows;
rails assets:precompile RAILS_ENV=production
git add .
git commit -m {message}
git push heroku master (push the code to the heroku again)
I tried to do it from your code and work fine.
When running my rails app locally, everything works fine. However, when deployed to a server, I get the following error:
ActionController::UnknownFormat (TasksController#index is missing a template for this request format and variant.
It's similar for all the pages. What could be the problem?
Rails version is 5.0.1. The deployed application is running on unicorn and nginx. I'm using slim templates. The same problem appears either if the views have .slim extension or .html.slim.
The slim gem might not be installed on your server. Try running bundle install on the command line in your app directory and then restarting your server.
I am new to rails from java enviroment. I have few confusions in asset pipeline with rails 3 to 4.
Currently I am in rails 4.2.5
I created a sample app on my local environment.
I created a new js from inside app/assets/javascripts and referencing it from the view , everything seems to working fine on my local environment.
After this I thought to test with production env how it works. Here are the steps I did.
RAILS_ENV=production rake assets:clean assets:precompile [All the files created public/assets]
Started the server in production mode rails server -e production
Now when i browsed the page I am getting this error,
"NetworkError: 404 Not Found - http://localhost:3000/assets/application-c5c431cb7c0a202f831a634922aaf1d536712002ae74334fb03ba4698b32b84c.js" in firebug.
When searched few threads , they suggest to add config.assets.compile = true. But I do not think so this is what the solution is, as it slows down the app.
Please help.
By default Rails4 will return a 404 if an asset is not handled via an
external proxy such as Nginx.
- https://github.com/heroku/rails_serve_static_assets
I suggest you have a look at the rails_12factor gem, which includes the rails_serve_static_assets gem which will allow your Rails app to serve static assets (like your .js file).
Edit:
You may not need a gem for this (though I've not tried it):
config.serve_static_files configures Rails itself to serve static
files. Defaults to true, but in the production environment is turned
off as the server software (e.g. NGINX or Apache) used to run the
application should serve static assets instead. Unlike the default
setting set this to true when running (absolutely not recommended!) or
testing your app in production mode using WEBrick. Otherwise you won't
be able use page caching and requests for files that exist regularly
under the public directory will anyway hit your Rails app.
- http://guides.rubyonrails.org/configuring.html
In Rails 5, this config method has been renamed to config.public_file_server.enabled, the rails_serve_static_assets gem handles the correct naming depending on version.
I am using the cloudinary with my application to upload images but I seem to get this error on development. I have the site launched and it gives this error when I try to upload an image.
Uncaught Missing required option: cloud_name
When I run it in development (localhost), it doesn't throw this error and works perfectly. Is this an issue in my production.rb or development.rb files? Did I forget to include something?
It's actually because I never pushed my keys to heroku with figaro. I'm using a Backbone.js frontend and a rails backend and I ignore my cloudname and API keys in gitignore so it was never on heroku.
I had to run:
figaro heroku:set -e production
and then it all worked :)
I used to develop a project on my own and now I have got some others to help in the project. It's developed with Ruby on Rails and we have a staging server on Heroku. Beforehand the deployment workflow is to precompile the assets in local machine then push the code to heroku. It works well when I am on my own.
Now I am working with a Front-end engineer. The problem is we are working in different location so it is difficult to setup his computer the same as mine. As a result, he will not be able to precompile the code before pushing to heroku.
Of course I can do it for him but would be better if he can just submit the code to the staging server and let Heroku to precompile it. I think Heroku detect if the manifest file is available to determine if it needs to precompile. Is there a way to force Heroku to recompile the assets?
I have tried: heroku run rake assets:clean then heroku run rake assets:precompile but no luck...
Heroku's servers use a read-only file system. This is how they make it easy for you to spin up more dynos, among other things.
Compiling Rails assets means taking the source files and compiling a new file, i.e. writing a file to the file system. Since this can't happen on a read-only file system, you have to precompile first. Even if you did manage to compile assets on Heroku, by writing to the /tmp directory, at the end of the day when Heroku reboots dynos, your new files will be gone because they weren't checked into the repo as they would've been if you had precompiled them locally, committed them, and then pushed to Heroku.
Any workaround I can imagine would be more complicated than helping your front end dev setup Rails and bundle installing the gems needed to precompile before pushing.