Mais conteúdo relacionado Semelhante a Timothy N. Tsvetkov, Rails 3.1 (20) Timothy N. Tsvetkov, Rails 3.16. Rails 3.1
2 years of development
1234 commits
321 Contributors
243244 coffee caps
1 dhh
12. Yes, all DB requests
actually in view
But, who care?
22. <%= yield :title %>
@posts = Post.cool_posts
<% content_for :title, "Projects" %>
23. <%= yield :title %>
@posts = Post.cool_posts
<% provide :title, "Projects" %>
42. class Post < ActiveRecord::Base
attr_accessible :title
attr_accessible :title, :user_id, :as => :admin
end
43. class Post < ActiveRecord::Base
attr_accessible :title
attr_accessible :title, :user_id, :as => :admin
end
Post.update_attributes(params[:post], :as => :admin)
45. class Filter < Struct.new(:klass)
def call(*args); end
end
module CategoryFilter
def call(category, *args)
klass.where(:category => args.shift)
super(*args)
end
end
class User < ActiveRecord::Base
scope :combined, Filter.new(self).extend(NameFilter)
end
51. AR options hash
:conditions, :include, :joins,
:limit, :offset, :order,
:select, :readonly, :group,
:having, :from, :lock