My favorites | Sign in
Project Logo
                
Search
for
Updated Apr 20, 2007 by timocratic
ExampleUsage  
Some usage examples

Get the basic 7 REST actions

class UsersController < REST::RestController
end

Pass in a custom sort to index

  def index(options = {})
    super :find_options => {:order => 'date DESC'}
  end

Override init with custom behavior

def show
    @report ||= Report.find_by_date(params[:date])
    @page_title ||= 'Sun Valley Fishing Report'
    super
  end

Pass in a custom editing template for error cases

  def create
    super :template => 'foo_edit'
  end

A mix of the above

  # Either index only exists in the parent controller, or it merges options and then calls super
  def public_index
    @page_title = 'Sun Valley Fishing Report'
    @body_class = 'archive'
    index :template => 'public_index'
  end

Sign in to add a comment
Hosted by Google Code