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:

  1. 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.
  2. 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.
  3. Run the rails_upgrade plugin to highlight areas of concern
  4. Upgrade the application to Rails 3
  5. Fix all concerns within your application itself, ignoring plugins for now
  6. Go through each plugin and gem, either installing newer versions that are Rails 3 compatible, or replacing / fixing them
  7. Run all specs and features and tests and make sure they pass
  8. Boot up and play around in your development environment
  9. Deploy on a staging environment to confirm your upgrade
  10. 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

  1. jaffa Says:

    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

  2. davecoast Says:

    Creating a program to have many new features and facilities is the eagerly awaited by many people that use of the program. This is good news foe many people used it/ moving companies san diego

  3. Sohan Says:

    The Drink Rails blog picked this post as one of the top ruby on rails blogs of the day.

  4. kenny Says:

    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?

  5. sareneoff Says:

    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.

  6. Bran Says:

    OK, I have made this upgrade but now I am getting some errors and don’t know what to do :(

  7. learn more Says:

    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.

  8. vegetable oil press Says:
    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.
  9. JimB Says:

    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!

  10. essay writing service Says:

    Excellent post and wonderful blog, I really like this type of interesting articles keep it u. I am really loving the theme/design of your web site.

  11. gh Says:

    sh

  12. jaffa Says:

    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

  13. jaffa Says:

    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

  14. CharlieBrown Says:

    I have not used this app so I will try this application. If indeed these applications can provide a lot of positive things on the blog that I have, I will use the application in the long term.
    Tibetan Yoga

  15. The Yoga of Discrimination Says:

    I have not used this app so I will try this application. If indeed these applications can provide a lot of positive things on the blog that I have, I will use the application in the long term. The Yoga of Discrimination

  16. CharlieBrown Says:

    I have not used this app so I will try this application. If indeed these applications can provide a lot of positive things on the blog that I have, I will use the application in the long term. The Yoga of Discrimination

  17. jhondenada Says:

    Using Smartphone is not easy. The software should be upgraded. Therefore, the performance is good. index futures

  18. Fishing Lodges Alaska Says:

    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

  19. Fishing Lodges Alaska Says:

    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

  20. fahmiboo Says:

    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

  21. jaffa Says:

    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

  22. hotel room Says:

    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.

  23. wallpaper murals Says:

    If I unable to listen this rails plugins coding, Then can say it is so effective post.

  24. jaffa Says:

    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

  25. charter yachts Says:

    I will try to do it like you said. I am sure that I will have excellent results

  26. jaffa Says:

    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.

  27. jaffa Says:

    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

  28. jaffa Says:

    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

  29. jaffa Says:

    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

  30. jaffa Says:

    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,
    web design companies

  31. jovaltrade Says:

    I have used rails a little bit, and so far I really like it.
    Fort McMurray Real Estate & Homes

  32. jovaltrade Says:

    This is a great, easy to understand tutorial on how to upgrade to the new Rails. Thanks from a newbie.
    Edmonton Real Estate & Homes

  33. shinkageru Says:

    There are several programs that are deliberately divided into sections with a variety of reasons there. This is perfectly normal and very common. shower grates

  34. idsamaren Says:

    There are many applications or many things that can be divided into several sections for the efficient use of space and time. You do have to use a lot of effective and efficient. 服飾批發

  35. benbricks Says:

    Something which is divided into several parts is usually a great thing and will not fit if put together. Therefore, we can indeed use a lot of consideration to this matter. glock magazines

  36. Aston martin hackett Says:

    There are many people who deliberately share many things in life. One way is to divide a lot of things associated with existing applications and programs.

  37. clarinet parts Says:

    If you want to repair your clarinet by your own then it is possible after some guideline. First of all you should be aware of some important clarinet parts. The screws are some of the most critical clarinet parts.

  38. sano Says:

    I saw a blog on internet, the title was “DMAA banned Australia”. The title attracted me. When I read the details I came to know that DMAA is being banned in Australia because of supposed health risks.

  39. andira sweet Says:

    If anyone of you is interested in bulking up without using illegal or dangerous supplements then it’s a better idea to have a hordenine supplement, but before using it you should be aware of hordenine side effects.

  40. andira sweet Says:

    I recently read an article on pramiracetam. The article was so informative. I came to know that pramiracetam increases the brain ability to synthesize choline. As it is a natural supplement so it an be purchased in bulk.

  41. enhance memory Says:

    I usually forget phone numbers, when I took my last meal and even names of my grand children. I want to enhance memory by using any effective supplement. My daughter suggested me to use racetams. Let’s see what happen.

  42. retail system Says:

    Nice Article, I feel strongly that love and read more on this topic. it’s very spectaculer.

    Mesin Kasir | Komputer Kasir | Jual Barcode | Printer Kasir

    Printer Kartu

  43. barcode system Says:

    I realy like this article. This is a hash of default values for any email you send, in this case we are setting from the header to a value for all messages in this class, this can be overridden on a per email basis..

    Mesin Kasir | Komputer Kasir | Jual Barcode | Printer Kasir

    Printer Kartu

  44. makong Says:

    I have a problem

    Old session store setting
    Previously, session store was set directly on ActionController::Base; it’s now config.session_store :whatever. help with business plan

    what to do?

  45. jay11 Says:

    Only aspire to mention ones content can be as incredible. This clarity with your post is superb and that i may think you’re a guru for this issue. High-quality along with your concur permit me to to seize your current give to keep modified by using approaching blog post. Thanks a lot hundreds of along with you should go on the pleasurable get the job done.
    jgef

  46. Lucifer Williams Says:

    This is a hash of default values for any email you send, in this case we are setting from the header to a value for all messages in this class, this can be overridden on a per email basis..SEO Austin

  47. Micheal Says:

    They include applications such as toolbars, download managers and video controllers. Although plugins make your browser more interactive, they can also cause errors and diminish display speed. IE seven makes it easy for you to disable browser plugins or delete plugins you no longer want.
    Regards,
    reputation management

  48. Micheal Says:

    They include applications such as toolbars, download managers and video controllers. Although plugins make your browser more interactive, they can also cause errors and diminish display speed. IE seven makes it easy for you to disable browser plugins or delete plugins you no longer want.
    Regards,
    reputation management

  49. mic1122 Says:

    I’ve been searching for some decent stuff on the subject and haven’t had any luck up until this point, You just got a new biggest fan!..
    Tips by Bonaca Seattle

  50. Arifiduor Says:

    I would highly recommend reading this book as your starting point for Rails 3 upgrade and with Rails 3 is this website.San Diego Auto injury relief 

  51. srinarax Says:

    The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.PS3 Emulator

  52. MrEmo Says:

    Thanks for such a great post and the review, I am totally impressed.Xbox Emulator

  53. vusftxtvseks Says:

    pfrroyorlzxg

  54. zguukkjycljz Says:

    esrzsqiifatb

  55. kgnbftewomft Says:

    auseeempcbzn

  56. Oprah Says:

    i like professionals working on this site

  57. iiqyzvfyhdeg Says:

    hjaeirlespyu

  58. sxkmoejvedjw Says:

    maagjwuzvodq

  59. srzxrshehjjj Says:

    olonzfzcyrrx

  60. fnghcgkdwkfb Says:
    this is a fantastic theme hxixthltom click here >:O svqxp, :( xkymktrcdq [url=“http://www.htfjgvvrpmtw.net”]or here[/url] :-/ arpoviyf, :/ gsnrscjrce http://htfjgvvrpmtw.info :-/ arpoviyf, :V wqhnwulahf [url=http://htfjgvvrpmtw.ru]tbzqokpvsb[/url] ;) udqujdhjbrekxyy, :3 skzwmbcixb [link=http://htfjgvvrpmtw.se]wgopiztsxe[/link] :-D udqujdhjbrekxyy, 3:)
  61. ctdngcoyfpcs Says:

    olloxowckzzg

  62. obtwrsfktjny Says:

    lzqivrhfyebd

  63. glcynkgtrkub Says:

    hwfefberfzqs

  64. Victor1122 Says:

    I was curious if you ever considered changing the page layout of your blog? Its very well written.
    אדריכל ומעצב

Leave a Reply