今天,徘徊在几个问题之间简单流水帐,复制一下
现在的Rails版本是3.0.7
看active record呢
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
http://api.rubyonrails.org/classes/ActiveRecord/Base.html
上面的官网API看起来很不错
之前版本如下
http://ar.rubyonrails.org/classes/ActiveRecord/Base.html
Company.where(
"id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
{ :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' }
).first
Student.where(:first_name => "Harvey", :status => 1)
Student.where(params[:student])
User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u|
u.is_admin = false
end
Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
> [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...]
关于relation
TreeMixin.find :all, :joins => :children
# => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
TreeMixin.find :all, :joins => {:children => :parent}
# => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
INNER JOIN parents_mixins ...
TreeMixin.find :all, :joins => {:children => {:parent => :children}}
# => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
INNER JOIN parents_mixins ...
INNER JOIN mixins childrens_mixins_2
在rails 3下卸载active record
引用
The rails command that generates the application template now has an option -O, which tells it to skip ActiveRecord.
If you don't feel like rerunning rails, you should check the following in your existing app:
Check that your config/application.rb doesn't have require 'rails/all' or require "active_record/railtie". Instead, for a standard Rails setup without ActiveRecord, it should have only the following requires:
require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
# Auto-require default libraries and those for the current Rails environment.
Bundler.require :default, Rails.env
If, in config/application.rb, you are using the config.generators section, make sure it doesn't have the line g.orm :active_record. You can set this explicitly to nil, if you want, but this should be the default when g.orm is completely omitted.
Optional, but in your Gemfile, remove the gem line that loads the module for your database. This could be the line gem "mysql" for example.