Synvert::Rewriter.new 'upgrade_rails_3_0_to_3_1', 'Upgrade rails from 3.0 to 3.1' do if_gem 'rails', {gte: '3.0.0'} within_file 'config/application.rb' do # insert config.assets.version = '1.0' unless_exist_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'version=' do insert "config.assets.version = '1.0'" end # insert config.assets.enabled = true unless_exist_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'enabled=' do insert 'config.assets.enabled = true' end # config.assets.prefix = '/assets' => config.assets.prefix = '/asset-files' with_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'prefix=', arguments: ['/assets'] do replace_with "config.assets.prefix = '/asset-files'" end end within_file 'config/environments/development.rb' do # remove config.action_view.debug_rjs = true with_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'action_view'}, message: 'debug_rjs=' do remove end # insert config.assets.debug = true unless_exist_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'debug=' do insert "config.assets.debug = true" end # insert config.assets.compress = false unless_exist_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'compress=' do insert "config.assets.compress = false" end end within_file 'config/environments/production.rb' do # insert config.assets.digest = true unless_exist_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'digest=' do insert "config.assets.digest = true" end # insert config.assets.compile = false unless_exist_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'compile=' do insert "config.assets.compile = false" end # insert config.assets.compress = true unless_exist_node type: 'send', receiver: {type: 'send', receiver: {type: 'send', message: 'config'}, message: 'assets'}, message: 'compress=' do insert "config.assets.compress = true" end end within_file 'config/environments/test.rb' do # insert config.static_cache_control = "public, max-age=3600" unless_exist_node type: 'send', receiver: {type: 'send', message: 'config'}, message: 'static_cache_control=' do insert 'config.static_cache_control = "public, max-age=3600"' end # insert config.serve_static_assets = true unless_exist_node type: 'send', receiver: {type: 'send', message: 'config'}, message: 'serve_static_assets=' do insert "config.serve_static_assets = true" end end new_code = "ActiveSupport.on_load(:action_controller) do\n" new_code << " wrap_parameters format: [:json]\n" new_code << "end\n" new_code << "\n" new_code << "ActiveSupport.on_load(:active_record) do\n" new_code << " self.include_root_in_json = false\n" new_code << "end" add_file 'config/initializers/wrap_parameters.rb', new_code within_file 'config/initializers/session_store.rb' do with_node type: 'send', receiver: {type: 'send', message: 'config'}, message: 'session_store', arguments: {first: :cookie_store} do session_store_key = node.receiver.receiver.source(self).split(":").first.underscore replace_with "{{receiver}}.session_store :cookie_store, key: '_#{session_store_key}-session'" end end todo <<-EOF Make the following changes to your Gemfile. group :assets do gem 'sass-rails', "~> 3.1.5" gem 'coffee-rails', "~> 3.1.1" gem 'uglifier', ">= 1.0.3" end gem 'jquery-rails' EOF end