Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To have AR support back after creating project with --skip-active-record option in rails 3

I have created a Rails 3 project with mentioned option. Can I somehow "revert" this option and have active record back as in default, or must I create a new project?


EDIT

Ok, to have ActiveRecord support back I had to:

  1. Delete separate require calls in application.rb and replace it with require 'rails/all' (or just uncomment # require "active_record/railtie")
  2. Uncomment # gem 'sqlite3-ruby', :require => 'sqlite3' line in Gemfile (for sqlite)
  3. Create database.yml file and fill it with options
  4. invoke rake db:create task

After that it seems that I can continue to work with AR as usual.

like image 584
Ernest Avatar asked Dec 02 '10 18:12

Ernest


People also ask

What is callback in Ruby on Rails?

Callbacks are methods that get called at certain moments of an object's life cycle. With callbacks it is possible to write code that will run whenever an Active Record object is created, saved, updated, deleted, validated, or loaded from the database.

What is application RB in rails?

The configuration file config/application. rb and environment-specific configuration files (such as config/environments/production. rb ) allow you to specify the various settings that you want to pass down to all of the components. For example, you could add this setting to config/application.rb file: config.

What is ActiveRecord in Ruby on Rails?

What is ActiveRecord? ActiveRecord is an ORM. It's a layer of Ruby code that runs between your database and your logic code. When you need to make changes to the database, you'll write Ruby code, and then run "migrations" which makes the actual changes to the database.

What's the purpose of ActiveRecord?

Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database. It is an implementation of the Active Record pattern which itself is a description of an Object Relational Mapping system.


1 Answers

Make a new project with ActiveRecord, and then pairwise diff config/application.rb and config/environments/*.rb to determine if there are any default settings you should add back to your project.

like image 74
yfeldblum Avatar answered Sep 28 '22 05:09

yfeldblum