http://www.javaeye.com/news/2320
has_one :through
- class Magazine <>
- has_many :subscriptions
- end
- class Subscription <>
- belongs_to :magazine
- belongs_to :user
- end
- class User <>
- has_many :subscriptions
- has_one :magazine, :through => : subscriptions, :conditions => ['subscriptions.active = ?', true]
- end
http://www.javaeye.com/news/2334
Gem: Dependencies
- Rails::Initializer.run do |config|
- # Require the latest version of haml
- config.gem "haml"
- # Require a specific version of chronic
- config.gem "chronic", :version => '0.2.3'
- # Require a gem from a non-standard repo
- config.gem "hpricot", :source => "http://code.whytheluckystiff.net"
- # Require a gem that needs to require a file different than the gem's name
- # I.e. if you normally load the gem with require 'aws/s3' instead of
- # require 'aws-s3' then you would need to specify the :lib option
- config.gem "aws-s3", :lib => "aws/s3"
- end
http://www.javaeye.com/news/2349
Dirty Objectshttp://www.javaeye.com/news/2367
- article = Article.find(:first)
- article.changed? #=> false
- # Track changes to individual attributes with
- # attr_name_changed? accessor
- article.title #=> "Title"
- article.title = "New Title"
- article.title_changed? #=> true
- # Access previous value with attr_name_was accessor
- article.title_was #=> "Title"
- # See both previous and current value with attr_name_change accessor
- article.title_change #=> ["Title", "New Title"]
- # Get a list of changed attributes
- article.changed #=> ['title']
- # Get the hash of changed attributes and their previous and current values
- article.changes #=> { 'title' => ["Title", "New Title"] }
Partial updatesActiveRecord::Base.partial_updates = true
- article = Article.find(:first)
- article.title #=> "Title"
- article.subject #=> "Edge Rails"
- # Update one of the attributes
- article.title = "New Title"
- # And only that updated attribute is persisted to the db
- article.save
- #=> "UPDATE articles SET title = 'New Title' WHERE id = 1"
http://www.javaeye.com/news/2377
named_scope
http://www.javaeye.com/news/2392
UTC-based Migration
http://www.javaeye.com/news/2417
http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/
http://wiki.rubyonrails.org/rails/pages/HowtoSetDefaultTimeZone
http://blog.labratz.net/articles/2007/4/11/rails-time-zone-guide-for-beginners
2008年8月8日 星期五
Rails 2.1 new features
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言