Upgrading jquery-ui-rails from 4.2.1 to 0.5.0


You would like to upgrade your jquery-ui-rails gem from a version before 0.5.x to the latest version 0.5.0, but when you do that your tests are failing with error messages similar to the one below:

couldn't find file 'jquery.ui.effect-blind'


According to the changelog the naming between 4.2.1 and 0.5.0 has changed jquery-ui-rails

So if you were using something like the following in your app/assets/javascripts/applications.js file (as used in the depot example in the Agile Web Development with Rails 4 book):

//= require jquery.ui.effect-blind

you would need to change it to the following after upgrading your jquery-ui-rails gem to ~> 0.5.0:

//= require jquery-ui/effect-blind

Upgrading from rspec-rails 2.x to rspec-rails 3.x


You would like to upgrade your rails project from using rspec-rails 2.x to the latest rspec-rails 3.x version. According to the rspec-rails documentation the new 3.x includes many breaking changes.


The full instructions for upgrading from rspec-rails 2.x to rspec-rails 3.x are here, but you may not need to complete all the steps described in there.
So you could try with the following shorter steps:

  • Run your rspec tests and make sure that they all pass
  • Upgrade your rspec-rails to the version 2.99 provided by the rspec-rails team
  • Run your rspec tests again, and you should have deprecation warnings. Usually that would consist of:
    spec-rails 3 will no longer automatically infer an 
    example group's spec type from the file location. 
    You can explicitly opt-in to this feature using 
    this snippet:
    RSpec.configure do |config|

    which you could add to your spec/spec_helper.rb file

  • Run your rspec tests again and this time they should have no deprecation warnings
  • If they all pass then upgrade to the latest rspec-rails (ie 3.0.1).
  • Run your rspec tests again, and this time you should normally have one deprecation warning:
    Requiring `rspec/autorun` when running RSpec via the `rspec` 
    command is deprecated. 
    Called from /xxx/xx/lib/active_support/dependencies.rb:247:
    in `require'.
  • Delete the line require ‘rspec/autorun’ from your spec/spec_helper.rb file
  • Rerun your tests and they should all be passing in rspec-rails 3.x now

bin/rails:6: warning: already initialized constant APP_PATH


You are getting the error:

bin/rails:6: warning: already initialized constant APP_PATH

when you are trying to start the local webserver with rails s.


That happens when are using the bootstrap rails gem as in:

gem 'anjlab-bootstrap-rails', require: 'bootstrap_rails'

It is important that the bootstap rails uses in the require is used with a dash and NOT an underscore.
So when you write the the gem as follows:

gem 'anjlab-bootstrap-rails', require: 'bootstrap-rails'

and restart your server you should no longer have the error message.

find out the status of rails application migrations


You would like to know at any moment the status of your migrations, if they have been applied, rolled back etc.


There is a very usefull rake task that can give you the list of your migrations withouth having to look at your schema.rb file:

rake db:migrate:status

Status   Migration ID    Migration Name
   up     20140528102449  Create products
   up     20140613150126  Create carts
   up     20140613151119  Create line items
   up     20140617215027  Add quantity to line items
   up     20140617220031  Combine
   up     20140620131542  Create orders
   up     20140620131605  Add order to line item

Rails 4 Application Development HOTSHOT review

A new book about rails 4 development has recently been published by Packt called Rails 4 application development HOTSHOT.

It is a book that can be described as a ruby on rails application cookbook. It focuses on the changes with the rails version 4 and includes a lot of the latest techniques and practices developing rails applications.

The book consists of 10 different projects, that can be used as the basis for further developing these applications.
The projects are:

  • Social Recipe-sharing Website
  • Conference and Event RSVP Management
  • Online Social Pinboard
  • Restaurant Menu Builder
  • Customisable CMS
  • Analytics Dashboard
  • Api Mashup – Twitter and Google maps
  • API only application
  • Video streaming website
  • Rails engines E-commerce

In each one of them different aspects of development are presented, for example twitter-bootstrap integration, devise authentication and so on.

So concluding this short review, this is a book that is recommended for ruby on rails developers with some previous experience, and it can provide the starting point for quite a few interesting projects.

rvm – Branch origin/ruby_2_1_0 not found.


You are trying to install the new ruby in your ubuntu rvm installation with rvm install 2.1 but you are getting the error:

Branch origin/ruby_2_1_0 not found.
There has been an error while checking out branch ruby_2_1_0.
Halting the installation.                               
There has been an error fetching the ruby interpreter. 
Halting the installation.


If you are careful and you notice a warning message as:

Warning, new version of rvm available '1.25.26', 
you are using older version '1.24.8'.

then you would need to update your rvm installation to the latest one with:

rvm update

And then you should be able to install the latest ruby version with:

rvm install 2.1

Upgrading and creating new virtualbox vagrant boxes from the standard precise32 box


You would like to use a current version of a Virtualbox vagrant box, based on the official precise32 box, like saucy32.


  • Build your first vagrant box using the precise32 box
  • Install any packages that you need
  • Upgrade your distribution by doing the following:
    1. Make sure that the package update-manager-core is installed and install it if it isn’t:
      sudo apt-get install update-manager-core
    2. Change the prompt from lts to normal in the file /etc/update-manager/release-upgrades:
      sudo vi /etc/update-manager/release-upgrades
    3. And upgrade to the next version by doing:
    4. sudo do-release-upgrade -d
  • Repeat the procedure for the version you want
  • Change the hostname to the current version:
    sudo vi /etc/hostname
    sudo vi /etc/hosts
  • Logout from the box and package it:
    vagrant package --output /home/path_to_new/packagename.box
  • Add the box to the list of boxes:
    vagrant box add quantal32 /home/path_to_new/packagename.box
  • You can use your new box now in a new vagrant box:

    vagrant init --packagename.box

Ruby on Rails and Django

There was a need recently to start a new web application using Python as the development language.

Having spent most of the last few years developing using Ruby with Ruby on Rails, this presented a nice challenge.
So the first thing, that needed some research was to be able to find a web framework in Python that is as close as possible to Ruby on Rails.

A quick web framework comparison and some web searches, indicated that the closest framework to Ruby on Rails, was Django.

So here I intend to list the similarities and the differencies of the two frameworks, as I go along the route and discover new things. The initial impression after a couple of days is that there is a surprising similarity between them, which hopefully will make the road smoother.

  • MVC In the Ruby on Rails we have Models, Views and Controllers. In Django that becomes Models, Templates and Views.
  • Package installation While in Ruby on Rails we have gem install in Django that becomes pip install
  • RVM(rbenv) To keep ruby versions and gems in different environments in Ruby we could use RVM or rbenv. On Python that is virtualenv
  • In Ruby on Rails we have an application but in Django we have a project that can contain multiple applications
  • Create a new application Because of the note above in Rails we create a new application with rails new app_name, where in Django we create the project first with django-admin.py startproject project_name and then the application with python manage.py startapp app_name
  • Database configuration In Ruby on Rails the database configuration can be found in the config/database.yml. In Django the database configuration, among other configuration options, is in the file project_name/settings.py
  • Starting the development web server With Ruby on Rails is rails s, on Django is python manage.py runserver
  • Running the console In Rails we can use rails c, and in Django python manage.py shell
  • Route information While in Ruby on Rails we set the routes in config/routes, in Django that takes place in project_name/urls.py and in app_name/urls.py
  • Deployment automation Capistrano for Ruby on Rails and Fabric for Django
  • Dependencies file is the Gemfile in Ruby on Rails and requirements.txt in Python’s virtualenv