Upgrading RailsPlugins.org to Rails 3 - Part 1
Tue May 18 04:34:07 -0700 2010
Note, this post has been recreated now that Rails 3 has been released. Please see: Updating Railsplugins.org to Rails 3
New version available
Please see the above new version, the below is old content and not really usable any more
Old content:
I am going to do a series of blog posts covering the upgrade of RailsPlugins.org to Rails 3. You can follow along as we go and comments or suggestions are welcome!
This upgrade was done using at least Rails 3 beta3. If try it on anything earlier, it will most likely go boom.
Process
Going about upgrading a non trivial site like RailsPlugins.org requires a process to make sure it works:
- Confirm the gems and plugins you are using either work with Rails 3, there are alternatives you can use, or you are interested in helping upgrade them – this is the most important step in terms of scope and time required to get the job done.
- Run all specs and features or tests and make sure they pass – if you don’t have any, then now would be a good time to install Cucumber and write at least features covering all the main user stories of your site.
- Run the rails_upgrade plugin to highlight areas of concern
- Upgrade the application to Rails 3
- Fix all concerns within your application itself, ignoring plugins for now
- Go through each plugin and gem, either installing newer versions that are Rails 3 compatible, or replacing / fixing them
- Run all specs and features and tests and make sure they pass
- Boot up and play around in your development environment
- Deploy on a staging environment to confirm your upgrade
- Deploy live and watch like a hawk.
I am going to document all these steps as part of upgrading the RailsPlugins.org site.
Confirm the gems and plugins you are using
Going through all the plugins and gems we use on the RailsPlugins.org site, showed up that most of them have Rails 3 versions available or listed as “Maybe”. I guess I’ll be helping people get it done! :)
Run all specs and features
I have good coverage on RailsPlugins.org and it is all green… so onward and upwards.
Run the upgrade plugin
The rails_upgrade plugin is hosted on github and up to date with all the latest bells and whistles of Rails 3, so we’ll use that:
$ script/plugin install git://github.com/rails/rails_upgrade.git
And then once installed, we do:
$ rake rails:upgrade:check
Which gives us pages of output, simplified down to:
Deprecated constant(s) Constants like RAILS_ENV, RAILS_ROOT, and RAILS_DEFAULT_LOGGER are now deprecated. More information: http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/ ... Deprecated session secret setting Previously, session secret was set directly on ActionController::Base; it's now config.secret_token. More information: http://weblog.rubyonrails.org/ ... Old session store setting Previously, session store was set directly on ActionController::Base; it's now config.session_store :whatever. More information: http://weblog.rubyonrails.org/ ... Deprecated ActionMailer API You're using the old ActionMailer API to send e-mails in a controller, model, or observer. More information: http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 ... Old ActionMailer class API You're using the old API in a mailer class. More information: http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 ... Soon-to-be-deprecated ActiveRecord calls Methods such as find(:all), find(:first), finds with conditions, and the :joins option will soon be deprecated. More information: http://m.onkey.org/2010/1/22/active-record-query-interface ... named_scope is now just scope The named_scope method has been renamed to just scope. More information: http://github.com/rails/rails/commit/d60bb0a9e4be2ac0a9de9a69041a4ddc2e0cc914 ... Old Rails generator API A plugin in the app is using the old generator API (a new one may be available at http://github.com/trydionel/rails3-generators). More information: http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators/ ... Old router API The router API has totally changed. More information: http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/ ... Deprecated ERb helper calls Block helpers that use concat (e.g., form_for) should use <%= instead of <%. The current form will continue to work for now, but you will get deprecation warnings since this form will go away in the future. More information: http://weblog.rubyonrails.org/ ... New file needed: config/application.rb You need to add a config/application.rb. More information: http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade ...
OK, so this might be too long for a single blog post, let’s take it in sections then.
Deprecated constant(s)
This section produced the following output:
Deprecated constant(s) Constants like RAILS_ENV, RAILS_ROOT, and RAILS_DEFAULT_LOGGER are now deprecated. More information: http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/ The culprits: - /Users/mikel/Code/railsplugins/lib/tasks/environments.rake - /Users/mikel/Code/railsplugins/lib/tasks/cucumber.rake - /Users/mikel/Code/railsplugins/lib/tasks/hoptoad_notifier_tasks.rake - /Users/mikel/Code/railsplugins/lib/tasks/rspec.rake
Which doesn’t seem too bad. I only really have one file in my application that is to blame, environments.rake, the other three are part of plugins that RailsPlugins.org uses, and I trust that the Rails 3 versions of these which we will update to later, should handle themselves.
Opening up environments.rake we see:
# Sets environments as needed for rake tasks
%w[development production staging].each do |env|
desc "Runs the following task in the #{env} environment"
task env do
RAILS_ENV = ENV['RAILS_ENV'] = env
end
end
task :testing do
Rake::Task["test"].invoke
end
task :dev do
Rake::Task["development"].invoke
end
task :prod do
Rake::Task["production"].invoke
end
This is a custom rake file we use to easily set environments for rake tasks. However, setting RAILS_ENV is deprecated in Rails 3. In Rails 3, you can set Rails.env directly with an assignment. So changing this rake task to be Rails 3 compatible would be:
# Sets environments as needed for rake tasks
%w[development production staging].each do |env|
desc "Runs the following task in the #{env} environment"
task env do
Rails.env = env
end
end
task :testing do
Rake::Task["test"].invoke
end
task :dev do
Rake::Task["development"].invoke
end
task :prod do
Rake::Task["production"].invoke
end
OK good. As I mentioned above, we are going to eave the cucumber, rspec and hoptoad files to be updated by their respective gems as we move along.
Deprecated session secret setting
The rails_upgrade plugin has pointed out the following:
Deprecated session secret setting Previously, session secret was set directly on ActionController::Base; it's now config.secret_token. More information: http://weblog.rubyonrails.org/ The culprits: - /Users/mikel/Code/railsplugins/config/initializers/session_store.rb Old session store setting Previously, session store was set directly on ActionController::Base; it's now config.session_store :whatever. More information: http://weblog.rubyonrails.org/ The culprits: - /Users/mikel/Code/railsplugins/config/initializers/session_store.rb
Which looks like this:
config/initializers/session_store.rb
ActionController::Base.session = {
:key => ‘_plugins_session’,
:secret => ‘somereallylongrandomkey’
}
In Rails 3, this process was changed quite significantly, with this commit, the upgrade though is very straight forward. First, you reduce session_store.rb to the following:
Rails.application.config.session_store :cookie_store, :key => "_my_app_name_session"
And then, because we now need somewhere to store the secret, you create a new file called config/initializers/cookie_verification_secret.rb and put inside of it:
Rails.application.config.cookie_secret = 'somereallylongrandomkey'
If instead of using cookies, you were using active record as the store, then you obviously wouldn’t need the cookie_verification_secret.rb file and instead would insert any other config you needed into its own file inside of initializers.
This gives us the added bonus of being able to exclude cookie secrets from source control systems.
In the next instalment, we’ll cover getting the RailsPlugins.org site actually up and running on Rails 3.
blogLater
Mikel




Mon Apr 30 21:40:43 -0700 2012
The host application provides services which the plug-in can use, including a way for plugins to register themselves with the host application and a protocol for the exchange of data with plug ins. Plug ins depend on the services provided by the host application and do not usually work by themselves. Conversely, the host application operates independently of the plug ins, making it possible for end users to add and update plug ins dynamically without needing to make changes to the host application. Thanks.
Regards,
Cheap custom papers writing service
Tue May 18 20:12:51 -0700 2010
The Drink Rails blog picked this post as one of the top ruby on rails blogs of the day.
Tue Oct 12 17:17:37 -0700 2010
Mickel,
I’m upgrading my application to rails 3. I did the following:
(1) I converted ActionController::Base.session = { :key => ‘_my_site’ } into Rails.application.config.session_store :cookie_store, :key => “_my_site”, and stored this in file “config/initializers/session_store.rb”.
(2) I converted ActionController::Base.session = { :secret => ‘my_session_secret_key’ } into Rails.application.config.cookie_secret = ‘my_session_secret_key’ and stored this in the file “config/initializers/cookie_verification_secret.rb”
(3) In my existing file “cookie_verification_secret.rb”, there was a ActionController::Base.cookie_verifier_secret = ‘my_verifier_secret’. I tried converting this into (a) Rails.application.config.secret_token = ‘my_verifier_secret’, and (b) MySite::Applicatin.config.secret_token = ‘my_verifier_secret’. In both cases, I kept getting the error “ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken)”, when I tried to delete an object (an existing post). I also placed the <%= csrf_meta_tag %> in my layout but it does not help. Do you have any suggestion?
Tue Nov 08 19:41:52 -0800 2011
I have not upgraded at this point. I am a bit nervous that all will work out well. I will probably do it first on my production machine and then go from there. I would be interested in hearing of others who have made the leap.
Tue Jul 19 00:31:05 -0700 2011
OK, I have made this upgrade but now I am getting some errors and don’t know what to do :(
Mon Aug 01 11:37:04 -0700 2011
I have not upgraded at this point. I am a bit nervous that all will work out well. I will probably do it first on my production machine and then go from there. I would be interested in hearing of others who have made the leap.
Mon Aug 08 02:41:17 -0700 2011 Great to read more articles from your side. No doubt it’s really a great article and I felt really great going through your blog post.
Sat Sep 24 16:11:40 -0700 2011
I am thinking about using a cloud computing host to host my websites. Will there be any problems with my websites when I migrate them over to the cloud hosting? I don’t want the new Rails plugins to cause any glitches during the migration. Thanks!
Tue Jan 10 02:40:24 -0800 2012
In most languages, local variables are automatic variables stored on the call stack directly. This means that when a recursive function calls itself, local variables in each instance of the function are given separate memory address space. Thanks.
Regards,
Personal statement services review
Wed Jan 11 00:55:17 -0800 2012
In programming languages with only two levels of visibility, local variables are contrasted with global variables. On the other hand, many ALGOL derived languages allow any number of levels of nested functions with private variables, functions, constants and types hidden within them. Thanks a lot.
Regards,
Douglasville bankruptcy attorneys
Fri Jan 13 06:15:25 -0800 2012
sh
Sun Jan 15 22:35:53 -0800 2012
The ergonomics of a program: the ease with which a person can use the program for its intended purpose, or in some cases even unanticipated purposes. Such issues can make or break its success even regardless of other issues. Thanks a lot.
Regards,
Winfield Estate
Thu Jan 19 21:49:04 -0800 2012
The amount of system resources a program consumes the less, the better. This also includes correct disposal of some resources, such as cleaning up temporary files and lack of memory leaks. Thanks a lot.
Regards,
James Wilson Morrice
Tue Jan 31 01:36:05 -0800 2012
The purpose of programming is to create a set of instructions that computers use to perform specific operations or to exhibit desired behaviors. The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic. Thanks.
Regards,
cv help
Sun Feb 05 20:28:06 -0800 2012
I have not upgraded abortion cost at this point. I am a bit nervous that all will work out well. I will probably do it first on my Types of Abortion production machine and then go from there. I would be interested in hearing of others who have made the leap.
Tue Feb 07 01:23:02 -0800 2012
Readability is important because programmers spend the majority of their time reading, trying to understand and modifying existing source code, rather than writing new source code. Unreadable code often leads to bugs, inefficiencies, and duplicated code. Thanks a lot.
Regards,
cordless chainsaw
Wed Feb 15 03:41:44 -0800 2012
Debugging is a very important task in the software development process, because an incorrect program can have significant consequences for its users. Some languages are more prone to some kinds of faults because their specification does not require compilers to perform as much checking as other languages. Thanks.
Regards,
toronto lofts
Sun Feb 19 13:16:54 -0800 2012
Using Smartphone is not easy. The software should be upgraded. Therefore, the performance is good. index futures
Mon Feb 20 10:42:26 -0800 2012
I think it’s very difficult to create an application using it. The language are also not same as the one in this era.
Fishing Lodges Alaska
Mon Feb 20 10:43:08 -0800 2012
I think it’s very difficult to create an application using it. The language are also not same as the one in this era.
Fishing Lodges Alaska
Tue Feb 28 22:26:38 -0800 2012
Improving Smartphone is likely to make these devices have got better performance. The brand new computer software package normally has better level of superior. Next, they’ll acquire brand-completely innovative factor. forex iphone
Sun Mar 11 04:37:01 -0700 2012
I had problem with the update and it was so complicated to get back to the last version I got, so this time I won’t be updating it anymore unless if one of my smart friends is here to help.
Mon Mar 19 22:11:49 -0700 2012
High level languages are compiled or interpreted into machine language object code. Software may also be written in an assembly language, essentially, a mnemonic representation of a machine language using a natural language alphabet. Assembly language must be assembled into object code via an assembler. Thanks.
Regards,
reversing my fibromyalgia with guaifenesin
Sun Mar 25 08:36:22 -0700 2012
The subject of this site keeps me thinking a lot.The main theme of the site is very outstanding and it is very much useful for the new readers like me. I was looking for this kind of sites for a long time. I am waiting eagerly for its further publications. It really keeps me amazing.
flatmate
Sun Mar 25 08:37:00 -0700 2012
The subject of this site keeps me thinking a lot.The main theme of the site is very outstanding and it is very much useful for the new readers like me. I was looking for this kind of sites for a long time. I am waiting eagerly for its further publications. It really keeps me amazing.
flatmate
Tue Mar 27 08:24:55 -0700 2012
If I unable to listen this rails plugins coding, Then can say it is so effective post.
Tue Mar 27 23:54:57 -0700 2012
Entering a program in assembly language is usually more convenient, faster, and less prone to human error than using machine language, but because an assembly language is little more than a different notation for a machine language, any two machines with different instruction sets also have different assembly language. Thanks.
Regards,
rv dealers
Fri Mar 30 21:16:59 -0700 2012
The programmer’s primary computer language is often prefixed to the above titles, and those who work in a web environment often prefix their titles with web. The term programmer can be used to refer to a software developer, software engineer, computer scientist, or software analyst. Thanks.
Regards,
click here
Wed Apr 11 23:21:33 -0700 2012
Start inputting your ideas into the program using commands in the appropriate programming language. If you encounter difficulties with programming the commands, visit the manual for the program you are using or download and follow an online tutorial. Thanks.
professional personal statement writers
Wed Apr 11 23:22:38 -0700 2012
Start inputting your ideas into the program using commands in the appropriate programming language. If you encounter difficulties with programming the commands, visit the manual for the program you are using or download and follow an online tutorial. Thanks.
professional personal statement writers
Wed Apr 18 02:00:33 -0700 2012
The ergonomics of a program: the ease with which a person can use the program for its intended purpose, or in some cases even unanticipated purposes. Such issues can make or break its success even regardless of other issues. This involves a wide range of textual, graphical and sometimes hardware elements that improve the clarity, intuitiveness, cohesiveness and completeness of a program’s user interface. Thanks.
Regards,
fort mcmurray real estate
Thu Apr 19 00:04:04 -0700 2012
I will try to do it like you said. I am sure that I will have excellent results
Tue Apr 24 20:50:48 -0700 2012
The instructions involved in updating financial records are very different from those required to duplicate conditions on an aircraft for pilots training in a flight simulator. Although simple programs can be written in a few hours, programs that use complex mathematical formulas whose solutions can only be approximated or that draw data from many existing systems may require more than a year of work. Thanks.
Fri Apr 27 04:10:43 -0700 2012
The simple programs can be written in a few hours, programs that use complex mathematical formulas whose solutions can only be approximated or that draw data from many existing systems may require more than a year of work. Thanks.
Regards,
phlebotomy.net