We now have Rails 4 support on Codelearn Playground . You can confirm the same by typing
rails -v in the Terminal inside your home directory.
What about my old Rails 3 app ?
Dont worry. If you go inside any of your old apps & type
rails -v, you would see that the Rails version is the same as defined in your Gemfile, which would be most probably Rails 3.2.13 unless you have fiddled with your Gemfile.
Will ‘rails new’ command create a Rails 4 app now ?
No. That would completely break our tutorial. Our tutorial follows Rails 3 conventions. There are some differences between Rails 3 & 4 conventions.
rails new command will still create a Rails 3.2.13 app for you. You can confirm the same by creating a test app, going inside it in Terminal & typing
rails -v to view the version.
How do I get a Rails 3 app while ‘rails -v’ in my home directory shows Rails 4 ?
Good question. We have hacked our way through this implementation. But first a small story.
I had earlier tweeted seeking a Rails expert who would be interested to upgrade Codelearn course to Rails 4. Manu S Ajith saw the tweet, quickly forked the public repos for your_site & shared_todo_app, changed the code to be compatible with Rails 4 & sent me his github repo links.
He went ahead to test the app on Codelearn Playground. Now this messed things a bit. We have a system wide Ruby & Gems installation using RVM. For the uninitiated, the Ruby & Gems (including Rails) lie inside /usr/local/rvm & not inside the home directory of a user.
So Manu cloned the github repos in his Codelearn Playground & did a ‘bundle install’. It upgraded the Rails binary to Rails 4.0.0 from Rails 3.2.13 . This happened on August 14. Now the issue was – anybody who created a Rails app ended up creating a Rails 4 app. It means that some of the instructions from the tutorial will not work as expected. I had to uninstall the Rails 4.0.0 version to get back the Rails 3.2.13. I did this within 12 hours of Manu upgrading Rails to version 4.0.0 .
This incident got me thinking. I took this as an opportunity to have Rails 4.0.0 on the system & also made sure not to break the tutorial instructions. How did I do it ? Well, we have a binary /bin/rails-codelearn that is aliased to the
rails command for Codelearn users. For
rails new, it eventually executes
rails _3.2.13_ new which creates a Rails 3 app. Thanks to Manu who pointed this hack to me.
So how do I create a Rails 4 app on Codelearn Playground ?
rails _4.0.0_ new your_app_name
to create a Rails 4 app. Once created, other Rails commands like
rails generate controller,
rails generate model etc would not require you to put _4.0.0_ in it.
I think I mistakingly created Rails 4 app. How do I downgrade ?
I have not done this myself, but I think its best to discard the directory (
rm -rf rails_app_directory) & start from scratch. Reason being, Rails 4 has some differences in configuration file as compared to Rails 3. If you are brave & want to figure your way out, follow the instructions below to change the Rails version inside your app.
Open your Gemfile, look for a line for the rails version. It should have ’4.0.0′. Change it to ’3.2.13′, do ‘bundle update’ & you should be good. To cross check, run
rails -v inside your app to see the Rails version.
If you created your app on August 14 or 15 on Codelearn, make sure to check your app’s Rails version. You should downgrade it to Rails 3.2.13 in case your are finding difficulties running your app in-spite of following instructions of Codelearn tutorial
Go ahead & create a Rails 4 app. Also, if you are interested to upgrade Rails course at Codelearn to Rails 4, do get in touch with me by either dropping a comment, tweeting to me at @pocha or dropping an email to firstname.lastname@example.org .