I am a newbie so please bear with me :)
I am currently working on my personal project running on rails 5.0.0.rc2. How can I best upgrade my project to use the latest version 5.0.0?
I did some research and found that I could just easily change the rails gem in Gemfile and run 'bundle update rails'. I don't know if this is the best way, but if it's not, what's the best way?
Thanks!
Go to your Gemfile, check gem 'rails' and set it's version like this
gem 'rails', '5.0.0'
the use bundle to install it by running
bundle install
or
bundle
you may encounter some dependencies that require you to run
bundle update
Changing the rails version in the Gemfile would be enough. Also be sure to check out railsdiff.org for changes in the project directory (config files, etc.)
Related
I'm using RVM to manage the different ruby versions I have. One particular application is using an older ruby version (2.3.1), and I've noticed that, once I've changed to that version and run rails server on it, it doesn't work because I'm required to change a whole cascade of Gems or other files, such as nokogiri, to make it run.
Generally, from what I've read online, I should just do a simple bundle install to do all of this before running rails server. However, it doesn't work as there are more conflicting things in this file, specifically that the versions are hard coded into it.
Based on this, how can I run this app on my local server, if the above steps I've done, just doesn't work? I'm using Ubuntu, if that helps.
You're dealing with what is known as dependency issues. The point of Gemfile and Gemfile.lock is to insure that there will be no dependency issues for the application and bundle install will handle that. However it is common for versions to be set in the Gemfile to lock to a specific major release version which might allow for minor version updates. This will look something like:
#Gemfile
gem 'rails', '4.2.10'
gem 'pg', '0.20.0'
gem 'after_party', '~> 1.10' #minor version updates will run here
gem 'kaminari', '~> 1.1'
ruby '2.3.6'
This ia a brief example. Now when you run bundle install it will make sure everything is compatible with these versions. While running bundle update will only update the versions with ~> before the version and will upgrade only minor semantic versions as they are not supposed to have breaking changes.
So, why is your app not working? Well the Gemfile should have contained a ruby version. RVM should determine your ruby version in .ruby-version file in base of your rails app and should match the version in Gemfile. If you need to upgrade your ruby version bundler will help insure all your gems are compatible with that version and with each-other. You'll first need to upgrade your ruby version with RVM, then set it in Gemfile.
However, there is no guarantee that out of date gems will be compatible. That's the whole point of locking them so that you know which versions are stable at a give point in time. Updates / upgrades to gems have to be tested for compatibility which can sometimes be a project.
Also see Rails Bundle, gems conflicts, best way to solve it
You can create a .rvmrc file or .ruby-version and .ruby-gemset files for isolating gems for your projects. Here's the official documentation on that - https://rvm.io/workflow/projects#project-file-ruby-version
you can add
echo '2.3.1' > .ruby-version and echo 'newgemset' > .ruby-gemset into working folder
then run
cd ./
rvm install ruby-2.3.1
gem install bundle
bundle install
I am learning Ruby on Rails and I find it annoying having to install and worry about gems and other dependencies for the apps I build . Does Rails have a way to install all your gems and dependencies for you ?
Yes. You have a file called Gemfile in the directory of your application.
Put all the gem you want to use in it.
And then just run bundle install to install all in one time (with dependencies) and later bundle update to update all your gem installed.
You can see Bundler: The best way to manage a Ruby application's gems and Ruby on Rails Tutorial for more informations.
I had the following near the top of my Gemfile:
gem 'rails'
I'm using rails 3.2.x and now when I ran bundle update, I got upgraded to rails 4.0 which I'm not ready for yet.
Can I simply delete my Gemfile.lock file, add the version number to gem 'rails' in my Gemfile and re-bundle install?
yes you can simple delete the gemfile.lock and re-bundle install,
or, add version number to rails and then do
bundle update.
If you're using git please do this.
git checkout -- Gemfile.lock
Yep, you can just delete the lock file, add the version to 'rails' and run bundle install.
AFAIK, that should do it.
In my Gemfile I have:
gem 'rails'
until yesterday it works well, my rails version was 3.2.9.
I've added no new gems and today, after running bundle update I see that it installs rails-0.9.5.
Why?
Running bundle update without specifying a gem to update is a bad idea if you haven't set the minor version in your Gemfile. The reason for this is because you will likely upgrade a gem that has a different public interface and it will break your application.
I'd recommend specifying the major and minor version of Rails in your Gemfile so that it "locks" it down so it will only upgrade the patch level:
gem "rails", "~> 3.2.9"
Then when you want to upgrade it, just run:
bundle update rails
This will update Rails to the latest patch (3.2.x) and as long as they are following semantic versioning, you won't have to worry about it breaking your app.
I added gem zero-clipboard-rails to Gemfile, run bundle install, and don't understand what is the next step?
zero-clipboard-rails doesn't work with the latest Rails Version.
I just released a gems to solve this issue.
zeroclipboard-rails.
Look at the github-pages for usage instructions.