Should I pin gem "rails" to a version? - ruby-on-rails-3

Most rails projects have a very specific version included in their gemfile, right after a rails new foo.
For example gem 'rails', '3.1.3'
Would it not be better to change this to allow dot-version and e.g. define rails as gem 'rails', '~>3.2'?
How is rails version-numbering done? I see major changes between dot-releases, e.g. upgrading from 3.0 to 3.1 requires quite severe changes (mostly to the asset pipeline). How is that for subreleases? Is 3.2.1 a bugfixonly release of 3.2.0?

There's not really any reason not to use the ~> constraint, but you should put:
gem 'rails', '~>3.1.3'
since that will mean any 3.1.x that is at least 3.1.3. Putting ~>3.1 implies compatibility with any Rails version 3.x.
Rails versioning follows semantic versioning, as far as I know.
However, I think the idea of specifying the exact version is that you read the release notes with every release and make a specific effort to validate that it's okay. Ultimately it's all up to you, though. You should be sure you're somehow following a feed for Rails versions so you always know about security releases either way.

Related

Neo4j.rb 2.0 and devise 2.0. Is there any way?

I want to use Neo4j database and JRuby on Rails to build a new web project. (I really need Neo4j or other graph database for this)
I am using neo4j 2.0 gem and trying to make authentication with Devise and Omniauth. Is there any way this combination will work?
I tried devise-neo4j but it is not compatible with neo4j.rb 2.0. I know that the last commit here says it is for neo4j.rb 2.0 but
gem 'neo4j'
gem 'devise-neo4j'
gives the following error when bundling:
Bundler could not find compatible versions for gem "neo4j":
In Gemfile:
devise-neo4j (>= 1.0.2) java depends on
neo4j (~> 1.1.1) java
neo4j (2.0.0.rc2)
I also tried the normal devise gem with neo4j:
gem 'neo4j'
gem 'devise'
but when I run rails g devise:install I get NameError: uninitialized constant User.
I searched and tried this a lot but couldn't get it working.
Does anyone know a good solution to this?
Or what is the right way to get this functionality (login with email/password and facebook,google,yahoo and twitter)? Oh, I know I can code it myself, but I would really like to use something already done.
My devise-neo4j fork is not released to rubygems.org, which means you have to specify it in the Gemfile file as:
gem 'devise', '1.5.3'
gem 'devise-neo4j', :git => 'git://github.com/andreasronge/devise-neo4j.git'
Notice that devise-neo4j does currently not work with devise 2.0.

Issues with Rails3.0 vs Rails 3.1

So I finally upgraded (and then downgraded because of Unity) Ubuntu and reinstalled RVM but I'b stuck with rails 3.1 now, which is fine but all my old projects are in rails 3.0 and 3.1 has some incompatibilities. Off the top of my head RAILS_ROOT is now Rails.root (which all my projects use in someway), and I was having some issues with heroku when trying to upload a small rails 3.1 app I made to play around (since the PG gem wasnt in my gemlist I couldnt run migrations, and then installing the pg gem caused more issues).
So how do I install rails 3.0 again? I cant seem to find it in the repositories
And I know with gem sets I can install both right? Well if I do that, how do I create a new rails project? Which version of rails would use rails new new_app?
Ok, I understand what you need to do. I would highly recommend making a new Gemset using RVM, that way you can start from scratch and not worry about those things.
To do that, run this in your command line with RVM installed:
// EDIT THIS LINE TO MATCH WHAT YOU WANT
rvm use 1.9.2-or-which-ever-version-you-are-using#temporary_gemset --create
Once this gemset is created, it will be empty, so you can then proceed to install a younger version of rails, like so:
gem install rails -v 3.0.11 // (MAY NEED TO USE SUDO, DEPENDING ON YOUR SET UP)
This should install the older version of rails and its dependencies so that you can still edit and work with your older rails project. Check more of RVM's site for more help on switching between gemsets and creating them.
https://rvm.io//gemsets/
I would still recommend to figure out the differences eventually and move to the newer version for Rails, currently 3.2.5 because they are awesome. Here is some material to show you the differences and new features for when you do that later:
http://railscasts.com/episodes/265-rails-3-1-overview
http://railscasts.com/episodes/282-upgrading-to-rails-3-1
http://railscasts.com/episodes/318-upgrading-to-rails-3-2

Attaching refinery cms to existing rails app version 3.1.1

I have an existing Rails app of version 3.1.1 and I am planning to add refinery cms to it. I have tried googling about it and have found few solutions.
I have placed following line in the gemfile:
gem 'refinerycms', :git => 'git://github.com/resolve/refinerycms.git'
On bundle install it is exiting in between giving the following output.
Bundler could not find compatible versions for gem "rails": In
Gemfile:
refinerycms depends on
rails (>= 3.1.3)
rails (3.1.1)
This is telling you that refinery needs at least version 3.1.3, while you're using 3.1.1. The changes between these two point releases are likely small enough that it should be a painless upgrade process.
Check whether you have rails version 3.1.1 specifically specified in your Gemfile and if so change it to gem "rails", "3.1.3".
Run bundle update rails

How to downgrade Rails version?

I create my rails application in version 3.0.7.
now i want to deploy my application, but the server is only support 3.0.3
how can i downloadgrade my application?
thanks
replace
gem 'rails','3.0.7'
with
gem 'rails', '3.0.3'
in your gemfile
Then run bundle
On a second note why not upgrade the server to rails 3.0.7?
Unless I'm mistaken... you can't. Well, you can, by:
Creating a new app
Bundle-installing all the necessary plugins, gems, etc
Copying over app files, configs, helpers, tests, everything
Running tests and seeing what doesn't now work
Making changes where required
Unfortunately, I don't believe there exists an easier way.

Why "bundle update" doesn't update the Gemfile to use Rails 3.0.5?

I tried using bundle update for a Rails 3.0.0 project I created, expecting all the content in Gemfile (and also Gemfile.lock) to reflect rails 3.0.5...
But it keep on being 3.0.0... even if I run bundle update rails, it still keep on being 3.0.0
Out of curiosity, I created a brand new Rails 3.0.0 project, and then run bundle update on it... and it still says "using rails 3.0.0", why? And how to make bundle update update to 3.0.5? (other than the obvious way to change the Gemfile by hand)
(I even tried changing sqlite3-ruby to sqlite3 in the Gemfile, because 3.0.5 seems to use sqlite3 instead. And rails and sqlite3 are the only 2 gems listed in Gemfile)
You already had the answer: change the gem version by hand and run bundle update rails.
I suspect you have gem 'rails', '3.0.0' in your Gemfile. Running bundle update rails won't change the version if you have the exact version specified.
Here's some info about the different ways of specifying gem versions in your Gemfile.
http://gembundler.com/rationale.html
Yeah you probably have
gem 'rails', '3.0.0'
change it to
gem 'rails', '~>3.0.0'
This will only upgrade minor versions of rails(3.0.5 & 3.0.6 ...). Or you can change it to
gem 'rails', '~>3.0'
if you want to upgrade to rails 3.1 but not 4.0
This is one of the top result when searching for "bundler wont update" on Google so I'm adding following as another answer. I was facing this issue in one of my projects.
In one of my projects I had a .bundle/config file which had following line:
BUNDLE_FROZEN: "1"
This was causing bundle update <gemname> to have no effect. I removed above line and it started updating again.