Migrating from Rails 2.3 to 3.2 over a long period - ruby-on-rails-3

I'm working on a small project that has been allocated a small amount of time to maintain and update features. This project is on Rails 2.3.
I'd like to move it to Rails 3.2 but there is little time allocated to this so I would like to do it over a slow gradual process.
I'm thinking that it might be worth moving over to Rails 3.2 on a section-by-section basis.
This would mean that I would create a second application that looks the same as the first one but is located somewhere different and accessed from a different subdomain.
Is this feasible if I just update the Rails 2.3 routes file for certain routes to go to the new application?
Has anyone done this before?

It depends on many parameters but among these the most relevant are :
Does your Rails 2 project already use Bundler ? If not, migrate to it before the migration.
Do you use gems which are known not to work on Rails 3 ?
Does your project already use Rails XSS plugin (https://github.com/rails/rails_xss) ? If not, migrate to it before the migration.
After that, the migration will be easier.
For the migration, I recommend that you create a brand new Rails application using "rails new" command, so that all the boot files will be good. Then migrate the initializers/config files and "app" folder...
Good luck.

Related

Rails 4 and Locomotive cms workarounds?

I want to try Locomotive CMS, while I was installing it, I realised that only runs with rails 3+ version no 4.
As I am currently working in a couple of other apps in rails and I am pretty new to it, I was wondering if is there any way to run one version of rails for locomotive and another one(rails 4) for my other apps. If so how could it be done?
Thanks in advance.
C
You definetely want to start using rvm. It will help you not only separate your gems for different projects, but also separate and manage your Ruby versions. Definetely a great tool.

Rails 3.2.2 Integrating spree in existing rails application. Migration table name conflict

I have full featured existing Rails 3.2.2 running application. I want to integrate the spree application with it.
I have followed the steps for adding Spree which are given in the Github http://github.com/spree/spree BUT I already have some tables with the same name which Spree has like 'addresses' and 'users'
The migrations are failing because of name conflict. when I tried
config.active_record.table_name_prefix = "spree_"
It started running all migrations from beginning and prepended spree_ to every table and got in conflict again because original table also get name like spree_addresses.
How should I go ahead for integrating the spree in existing application.?
Unfortunately, it will be quite tough. You somehow must merge both spree and your apps user models and addresses models to make them compatible.
Easiest would be to start from scratch and install spree. I was in your situation and ended up with a fresh rails app.

Libraries classes in Ruby on rails

I'm going to develop an application on Ruby on Rails which has many library classes. But I have no such idea. Is it possible or not in Rails? If possible, how can I develop my own library class in rails application? Please suggest me.
since i do not understand your question very well, i can only guess what you mean.
there are several ways of abstracting logic in ruby and ruby on rails.
the most general approach is creating ruby gems. this is a package of ruby code that can be used in every ruby project. it's possible to hook into rails through gems via railties.
there are two things that are specific to rails. the first one are plugins, that work very similar to gems and are considered a legacy way of providing functionality, but there are still some plugins around, especially for rails apps prior version 3.
the other thing is engines. these are micro-applications that can be mounted into any rails app. they are self-contained and can provide a lot of functionality based on their namespaced routes.
since rails is based on rack, it's also possible to hook any rack-conform ruby application into the rails router. through this approach it's possible to connect rails apps with ie. sinatra applications.

Rails 3.2 + Require.js?

I've been reading a lot of info on Require.js. AMD seems very interesting and I got it to work in a standalone backbone.js app. However, Sprocket in Rails seems to conflict with it. Do you recommend projects to go with standard Rails asset pipeline without Require.js?
I saw this article but it's for Rails 3.1, so not sure if it's still applicable: Using RequireJS with a Rails 3.1 app
Also, Underscore no longer seems to be supporting AMD. I don't want to use yet another package to work with Backbone.
I did this awhile ago I used the "use" requireJS plugin to load incompatible libs like underscore.js
https://github.com/tbranyen/use.js
and I think I only included require.js into the sprockets assets, and used it like in any other application.

Upgrade Rails 2.3.14 to Rails 3.1.0, or re-write app fresh in Rails 3.1.0

I have upgraded my app to Rails 3.1.0, and while I have solved many compatibility issues, but I have also noticed that there are many redundant files, junk codes, and some features I have to recode again.
I am just wondering if I should just rewrite my app from fresh in Rails 3.1.0, or continue modifying and fixing after the upgrade? The former one will produce a cleaner app, but more work, and the latter one will be faster, but will also take some time to clean up the mess. What is my best approach?
Thanks.
what I do is create a fresh empty rails 3.1 app. Install my gems with bundler. Then I copy over my migrations, my models and my spec tests. Run my tests. Get tests passing, resolve any incompatibility issues. Repeat with config/routes, controllers, views, etc.