Asset Pipeline Issue Upgrading Rails 3.0 app to Rails 3.2 - ruby-on-rails

I've followed the instructions for the Railscast on upgrading a Rails app to 3.1:
http://railscasts.com/episodes/282-upgrading-to-rails-3-1?view=asciicast
The server doesn't recognize requests for any folders within app/assets.
Just to be sure, I've run rake rails:update and diff'd the files against what we have. It looks like every old config flag has been removed and every new config flag has been set.
When I load the homepage, I see the following in the javascript console:
"NetworkError: 404 Not Found - http://localhost:3000/assets/application.js"
"NetworkError: 404 Not Found - http://localhost:3000/assets/application.css"
Does anyone have any suggestions? I'm completely stumped, short of creating a new app and moving things over.

The issue was with the active_reload gem in our project. Disabling it in the gemfile and running bundle install fixed the issue
Apparently the first statement on the project page is that it's incompatible with Rails 3.2.x.

Related

Rails on Heroku - Site does not load - ActionView::Template::Error (The asset "image.jpg" is not present in the asset pipeline.)

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.

Is my rvm directory structure in a weird state?

I don't really know where to turn on this one. Due to an unfortunate situation, I'm in the middle of a rebase which is trying to add ember to a project while upgrading to rails 4.1 and ruby 2.1.1 at the same time (the rails and ruby upgrades were merged into the project while I was on the add ember branch). I'm getting all sorts of dependency errors when trying to get a rails server up.
Some of the errors included:
bin/rails:8: warning: already initialized constant APP_PATH
/home/amax/git/forever/bin/rails:8: warning: previous definition of APP_PATH was here
cannot load such file -- websocket/driver
cannot load such file -- active_model_serializers
One thing I noticed was that my rvm path has 2.1.1 and 2.1.0 in it which I'm guessing is a bad sign. I'm thinking it may be loading old gems
root/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.....
Does anyone know if this could cause problems and any suggestions on a possible remedy?
The errors seemed to change every time and it seemed to be the fault of an irredeemably screwed up gemfile.lock that I caused during the rebase.
I started from a new branch with rails 4.1.1, added ember to it and then copied and pasted that working gemfile.lock over the broken one which resolved all of the issues. If you get into a similar situation I think it may be worth a try to blast away your gemfile and gemfile.lock and recreate them in a stable environment

Downgrading from Rails 3.2.6 to 3.0.11

I am facing issue when I am trying to work with rails 3.0.11. I initially worked with rails 3.2.6. Build a prototype application in Rails 3.2.6, Ruby 1.9.2 and gem 1.8.7. But then found, server on which we need to host is a shared server which can only support Rails 3.0.11, Ruby 1.8.7 and gem 1.7.2.
Hence I want to keep my dev environment exactly same before I ran into further issues. As I found there was some discrepancy in routes.rb of both the versions.
Steps I followed:
Uninstalled rails
Uninstalled ruby
Installed ruby from here.
This installed ruby version 1.8.7-p370 and gem 1.8.7
After this I installed rails by specifying version as 3.0.11
But still when I run command rails -v, it throws an error to me saying 'missing gem rails 3.2.6. Run bundle install to resolve the issue'
When I ran bundle install, it again completely installed rails 3.2.6 and problem remained unresolved.
Please suggest the clean way how shall I start my development on rails 3.0.11 without running into any issues?? Am I need to delete some registry or mapping in my system through which it is detecting rails 3.2.6 and creating issues??
Its urgent as I need to complete my dev by 7th September.
As I am new to stackexchange, please guide is it appropriate to ask question on the same related thread or shall I open new discussion for my problem?
#Gun - please note in response to one of your comments posted above - you DO need to change your Gemfile - if you are running rails -v from withing your project's directory, it will read the Gemfile.
There is a script located at script/rails - this is what runs when you run the rails command from the project directory. NOTE that this rails script requires your config/application.rb file - which in turn reads the Gemfile and bundles the referenced gems. Thus is your Gemfile still references 3.2.6, and it is not installed, rails -v will not work
Glad to hear the problem is fixed :)
As for the asset pipeline - if you are using rails 3.2.6 (or were using it) then you may have been using the asset pipeline to serve your assets (javascript files, CSS files, images, etc). If you were, and you downgrade to anything pre rails version 3.1, then anything being served through the asset pipeline will no longer work.
Here is a pretty good description of the asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html
You should check also remove your Gemfile.lock or manually 'bundle update rails' when you change your rails dependency.
I suggest to use rbenv or rvm to create a virtual environment/sandbox where you can install your preferred ruby versions (e.g. 1.8.7) and keep tracking of your dependencies separately. This would save you a lot of effort.
Keep in mind that rails 3.0 has no asset pipeline support (it has been included in rails 3.1)! This is a very important difference and if you depend on it you will have big issues to solve for the downgrade.
Thanks a lot everyone for help.
I believe it was weird issue. I had heroku on the system. I was initially deploying my app on the same and then changed to another hosting server.
After uninstalling the heroku, it works perfectly fine. Probably, that was interfering somewhere. Although, not sure but problem is resolved.
Thanks a lot again for a great great help!!!
Meanwhile, I would request alup to throw some more light on asset pipeline support. Wots that? Could you please explain more??
Need to delete C:\Users\.ror folder and C:\Users\.gemfile and C:\Users\.gemfile.lock from your desktop..

Rails 3.2 Upgrade - Vendor/Plugins Issue

Good afternoon,
I just upgraded my Rails app from 3.1.3 to 3.2.1. Everything is working on my local development machine (in development or production modes). There is no trace left of my vendor/plugins directory (or even the vendor directory at all).
However, after committing to git and pushing to Heroku, I'm getting warnings about deprecation of my rails 2.3 style vendor/plugins. Crazy seeing as I have no vendor directory at all!
Do I need to totally wipe my Heroku files? (If so, how would I do this?) Any other suggestions appreciated.
I've seen this and it looks like warnings about some of the stuff that Heroku injects into your code for things such as asset serving etc.
I'm assuming that as more and more start to use Rails 3.2 that Heroku will fix this. I wouldn't worry about it - the deprecation won't kick in until Rails 4.0 and that's some way off.

After upgrading to Rails 3.1.1: "undefined method `javascript_expansions'" error

Ive upgraded rails from 3.0.10 to 3.1.1 and now Im getting the following Error:
undefined method 'javascript_expansions' for ActionView::Helpers::AssetTagHelper:Module
but not on every page, just some pages are involved. I googled it already but I didnt find anything! Im running ruby 1.9.2 by the way...
Also my asset pipeline doesnt seem to work. Its not loading the application.cssand application.js file even its in the assets subfolders. Im getting a routing error each time I try to fetch any of the files.
I got the exact same error, after removing tinymce and running bundle install everything was running smooth, so heat up the coffee machine and try to remove suspect JavaScripts.
Maybe it was just a lucky shoot he he
I solved this problem adding the therubyracer gem to the Gemfile and runned bundle install. Thats it...

Resources