RailsCasts Pro episodes are now free!
Learn more or hide this
Resources
Product.find_by_price(3) # => nil Product.find_by_price!(3) # => RecordNotFound Exception Product.find_last_by_price(4.99) Product.all(:joins => :category, :conditions => { :categories => { :name => 'Clothing' } })
def admin_area(&block) if admin? concat content_tag(:div, capture(&block), :class => 'admin') end end
<% admin_area do %> <%= link_to "Edit", edit_product_path(@product) %> | <%= link_to "Destroy", @product, :confirm => 'Are you sure?', :method => :delete %> <% end %>