Rails3Tasks » History » Version 21
Luis Figueira, 2013-01-08 12:42 PM
1 | 1 | Chris Cannam | h1. Moving to Rails 3 |
---|---|---|---|
2 | 1 | Chris Cannam | |
3 | 1 | Chris Cannam | h2. Test environment |
4 | 1 | Chris Cannam | |
5 | 1 | Chris Cannam | We have a Redmine 2.2 pristine branch (redmine-2.2) and an integration branch (redmine-2.2-integration) in which to fix errors arising from merging our own changes back in to Redmine 2.2. |
6 | 1 | Chris Cannam | |
7 | 1 | Chris Cannam | For Rails 2, we have been using Ruby Enterprise Edition v1.8.7 with Phusion Passenger v3.0.1. |
8 | 1 | Chris Cannam | |
9 | 1 | Chris Cannam | For Rails 3 we want to use a more mainstream Ruby v1.9.3, with Phusion Passenger v3.0.18. |
10 | 2 | Chris Cannam | |
11 | 2 | Chris Cannam | Ubuntu 10.04 LTS only has Ruby 1.9.1, so we use the Brightbox packages. |
12 | 2 | Chris Cannam | |
13 | 2 | Chris Cannam | <pre> |
14 | 2 | Chris Cannam | $ sudo apt-add-repository ppa:brightbox/ruby-ng |
15 | 2 | Chris Cannam | $ sudo apt-get update |
16 | 2 | Chris Cannam | $ sudo apt-get install ruby1.9.3 |
17 | 2 | Chris Cannam | $ sudo gem1.9.3 install rails |
18 | 2 | Chris Cannam | $ sudo gem1.9.3 install passenger |
19 | 2 | Chris Cannam | $ sudo apt-get install libcurl4-openssl-dev |
20 | 2 | Chris Cannam | $ sudo passenger-install-apache2-module |
21 | 2 | Chris Cannam | </pre> |
22 | 3 | Chris Cannam | |
23 | 3 | Chris Cannam | The Passenger installer prints out: |
24 | 3 | Chris Cannam | |
25 | 3 | Chris Cannam | <pre> |
26 | 3 | Chris Cannam | Please edit your Apache configuration file, and add these lines: |
27 | 3 | Chris Cannam | |
28 | 3 | Chris Cannam | LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-3.0.18/ext/apache2/mod_passenger.so |
29 | 3 | Chris Cannam | PassengerRoot /var/lib/gems/1.9.1/gems/passenger-3.0.18 |
30 | 3 | Chris Cannam | PassengerRuby /usr/bin/ruby1.9.1 |
31 | 3 | Chris Cannam | </pre> |
32 | 3 | Chris Cannam | |
33 | 3 | Chris Cannam | (Note that the Brightbox PPA "Ruby 1.9.1" is in fact 1.9.3, unlike the Ubuntu repo package which is 1.9.1 -- confusing) |
34 | 4 | Chris Cannam | |
35 | 5 | Chris Cannam | Although the different versions of Ruby and Rails can coexist, the Passenger Apache module can be loaded once per Apache instance only, so introducing the new version will supersede entirely the old one. The Rails version is specified in each application config, but they will all get the same Ruby version. |
36 | 6 | Chris Cannam | |
37 | 6 | Chris Cannam | So, we make the above change (in @mods-available/passenger.load@) and the existing sites break with "Ruby on Rails version '2.3.14' not found" -- fair enough, it isn't installed for the new version of Ruby. Rather than fix this, let's keep the situation simpler to understand by blundering into the world of Rails 3 only. |
38 | 7 | Chris Cannam | |
39 | 8 | Chris Cannam | I'm also going to remove /usr/local/bin (i.e. REE) from the PATH: |
40 | 8 | Chris Cannam | |
41 | 8 | Chris Cannam | <pre>$ echo $PATH |
42 | 8 | Chris Cannam | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games |
43 | 8 | Chris Cannam | $ PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/games |
44 | 8 | Chris Cannam | </pre> |
45 | 8 | Chris Cannam | |
46 | 12 | Chris Cannam | (@/usr/games@ ??) Unfortunately we seem to have @bundle@ for Ruby 1.9 installed in /usr/local/bin, so |
47 | 1 | Chris Cannam | |
48 | 12 | Chris Cannam | <pre> |
49 | 12 | Chris Cannam | $ sudo /usr/local/bin/bundle install |
50 | 12 | Chris Cannam | </pre> |
51 | 12 | Chris Cannam | |
52 | 11 | Chris Cannam | Now, to the web instance and @hg pull -u; hg update redmine-2.2-integration@. Then |
53 | 11 | Chris Cannam | |
54 | 11 | Chris Cannam | <pre> |
55 | 11 | Chris Cannam | $ RAILS_ENV=development rake1.9.3 db:migrate |
56 | 10 | Chris Cannam | </pre> |
57 | 13 | Chris Cannam | |
58 | 13 | Chris Cannam | And now we're into application incompatibility territory: |
59 | 13 | Chris Cannam | |
60 | 13 | Chris Cannam | <pre> |
61 | 13 | Chris Cannam | DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /var/www/test-cannam/Rakefile:7) |
62 | 13 | Chris Cannam | Plugins in vendor/plugins (/var/www/test-cannam/vendor/plugins) are no longer allowed. Please, put your Redmine plugins in the `plugins` directory at the root of your Redmine directory (/var/www/test-cannam/plugins) |
63 | 13 | Chris Cannam | </pre> |
64 | 14 | Chris Cannam | |
65 | 14 | Chris Cannam | Before we try to fix all the application incompatibilities, let's try the pristine Redmine 2.2. |
66 | 14 | Chris Cannam | |
67 | 14 | Chris Cannam | h3. Pristine Redmine 2.2 |
68 | 14 | Chris Cannam | |
69 | 14 | Chris Cannam | <pre> |
70 | 14 | Chris Cannam | $ hg update redmine-2.2 |
71 | 14 | Chris Cannam | $ rm -rf vendor/plugins # nothing here but leftover crap anyway |
72 | 14 | Chris Cannam | $ RAILS_ENV=development rake1.9.3 db:migrate |
73 | 14 | Chris Cannam | rake aborted! |
74 | 14 | Chris Cannam | Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.) |
75 | 14 | Chris Cannam | </pre> |
76 | 14 | Chris Cannam | |
77 | 14 | Chris Cannam | This is a misleading error message -- see "here":http://stackoverflow.com/questions/9714965/how-to-resolve-please-install-the-mysql-adapter-gem-install-activerecord-mysql. We need to change the db adapter in config/database.yml from @mysql@ to @mysql2@. Next up, |
78 | 14 | Chris Cannam | |
79 | 14 | Chris Cannam | <pre> |
80 | 14 | Chris Cannam | Please remove config/initializers/session_store.rb and run `rake generate_secret_token`. |
81 | 14 | Chris Cannam | Setting the session secret with ActionController.session= is no longer supported in Rails 3. |
82 | 14 | Chris Cannam | </pre> |
83 | 14 | Chris Cannam | |
84 | 14 | Chris Cannam | OK, I'm going to rename that file rather than remove it (in case we need to go back) and then run the rake task. |
85 | 14 | Chris Cannam | |
86 | 14 | Chris Cannam | <pre> |
87 | 14 | Chris Cannam | $ mv config/initializers/session_store.rb config/initializers/session_store.rb_rails2 |
88 | 14 | Chris Cannam | $ RAILS_ENV=development rake1.9.3 generate_secret_token |
89 | 15 | Chris Cannam | $ RAILS_ENV=development rake1.9.3 db:migrate |
90 | 14 | Chris Cannam | </pre> |
91 | 15 | Chris Cannam | |
92 | 15 | Chris Cannam | The @migrate@ now succeeds (there does not appear to be a separate @db:migrate:plugins@ any more?) and we can restart the server, for an apparently working Redmine 2.2 instance. |
93 | 16 | Chris Cannam | |
94 | 16 | Chris Cannam | h3. Back to our application |
95 | 16 | Chris Cannam | |
96 | 16 | Chris Cannam | OK, so the pristine code works. Now |
97 | 16 | Chris Cannam | |
98 | 16 | Chris Cannam | <pre>$ hg update redmine-2.2-integration |
99 | 16 | Chris Cannam | </pre> |
100 | 16 | Chris Cannam | |
101 | 16 | Chris Cannam | and take it from here Luis! |
102 | 17 | Luis Figueira | |
103 | 20 | Luis Figueira | h2. Working wit the the integration branch |
104 | 18 | Luis Figueira | |
105 | 18 | Luis Figueira | h3. Moving plugins |
106 | 17 | Luis Figueira | |
107 | 17 | Luis Figueira | Needed to move all the plugins from vendor/plugins to plugins/. |
108 | 17 | Luis Figueira | |
109 | 17 | Luis Figueira | To do this I used hg rename: |
110 | 17 | Luis Figueira | |
111 | 17 | Luis Figueira | <pre> |
112 | 17 | Luis Figueira | for i in `ls vendor/plugins`; do echo hg rename vendor/plugins/$i plugins/$i; done | sh |
113 | 1 | Chris Cannam | </pre> |
114 | 20 | Luis Figueira | |
115 | 20 | Luis Figueira | I also needed to completely remove the vendor/plugins folder and any remaining files (temporary files from the editors, for instance). |
116 | 21 | Luis Figueira | |
117 | 21 | Luis Figueira | h3. Database adapter |
118 | 21 | Luis Figueira | |
119 | 21 | Luis Figueira | In my localhost I had to install the mysql-adapter. I added it to my gemfile.local file. |