addons/activerecord.rb in tiny-rails-0.0.2 vs addons/activerecord.rb in tiny-rails-0.1.0
- old
+ new
@@ -1,16 +1,19 @@
gem 'activerecord', '~> 3.2'
gem 'sqlite3'
template 'activerecord/models.rb', 'models.rb'
+
require_models_code = <<-CODE
# Enable code reloading for models
require_dependency 'models'
CODE
-inject_into_file 'tiny_rails_controller.rb', "\n#{require_models_code}", :after => /class TinyRailsController < ActionController::Base/
+inject_into_file 'application_controller.rb', "\n#{require_models_code}", :after => /class ApplicationController < ActionController::Base/
-config_db_code = <<-CODE
+application <<-CODE
+ # We need to override the configuration method here, otherwise Rails will
+ # try to load the yaml configuration file at config/database.yml
def config.database_configuration
{
'development' =>
{
'adapter' => 'sqlite3',
@@ -19,10 +22,11 @@
'timeout' => 5000
}
}
end
CODE
-application "\n#{config_db_code}"
+
+inject_into_file 'boot.rb', "\nrequire \"active_record/railtie\"", :after => /require ['"]action_controller\/railtie['"]/
template 'activerecord/migrate', 'migrate'
chmod 'migrate', 0755
append_to_file '.gitignore', 'db.sqlite3'