rails3 default_scope und Standardspaltenwert in migration
class CreateCrews < ActiveRecord::Migration
def self.up
create_table :crews do |t|
t.string :title
t.text :description
t.boolean :adult
t.boolean :private
t.integer :gender_id
t.boolean :approved, :default => false
t.timestamps
end
end
def self.down
drop_table :crews
end
end
class Crew < ActiveRecord::Base
has_many :users, :through => :crew_users
belongs_to :user
default_scope where(:approved => true)
end
Wenn ich zur Konsole gehe und einen neuen Datensatz erstelle, wird die Eigenschaft "approved" auf true gesetzt. Warum?
Wie kann ich den Standardwert (false) wie in meiner Migrationsdatei angegeben automatisch einstellen?
wojciech@vostro:~/work/ze$ rails console Loading development environment (Rails 3.0.0) ruby-1.9.2-p0 > c = Crew.new
=> #<Crew id: nil, title: nil, description: nil, adult: nil, private: nil, gender_id: nil, approved: true, created_at: nil, updated_at: nil, logo_file_name: nil, logo_content_type: nil, logo_file_size: nil, logo_updated_at: nil>