This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[13:20][ian@ian-terrells-macbook-pro:~/src/test/i18ntest]$ ./script/console | |
Loading development environment (Rails 2.3.2) | |
>> o = Order.create | |
=> #<Order id: 1, created_at: "2009-05-25 17:21:00", updated_at: "2009-05-25 17:21:00"> | |
>> t = OtherThing.create | |
=> #<OtherThing id: 1, created_at: "2009-05-25 17:21:05", updated_at: "2009-05-25 17:21:05"> | |
>> o.payments.create | |
=> #<Payment id: 1, payable_id: 1, payable_type: "Order", created_at: "2009-05-25 17:21:11", updated_at: "2009-05-25 17:21:11"> | |
>> o.payments.create | |
=> #<Payment id: 2, payable_id: 1, payable_type: "Order", created_at: "2009-05-25 17:21:13", updated_at: "2009-05-25 17:21:13"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book < ActiveRecord::Base | |
belongs_to :publisher | |
belongs_to :author, :select => [:id, :name], :conditions => "name != 'jax'" | |
belongs_to :another, :class_name => "SomeModel" | |
has_many :revisions | |
has_many :editors, :through => :revisions | |
has_one :something |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book extends ActiveRecordModel { | |
static $belongs_to = array( | |
array('publisher'), | |
array('author', 'readonly' => true, 'select' => 'name', 'conditions' => "name != 'jax'"), | |
array('another', 'class_name' => 'SomeModel') | |
); | |
static $has_many = array( | |
array('revisions'), | |
array('editors', 'through' => 'revisions') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This lets you define user roles as methods, | |
# i.e. checking the role of "admin" on a user | |
# will delegate to user.admin? | |
# | |
# This is helpful because in ActiveRecord, boolean | |
# attributes automatically have their query method | |
# defined; a boolean field "admin" will define | |
# the "admin?" method for you. | |
# | |
# If your logic is more complex, you can write your |
NewerOlder