Class: BeerDbAdmin::BreweriesController

Inherits:
BeerDbAdminController show all
Defined in:
app/controllers/beer_db_admin/breweries_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/beer_db_admin/breweries_controller.rb', line 7

def index
  order = params[:order] || 'title'

  if order == 'key'
    order_clause = 'key'
  elsif order == 'hl'
    order_clause = 'prod desc, title'
  else   # by_title
    order_clause = 'title'
  end
  
  # note:  show 25 per page for now

  @breweries = Brewery.limit(25).order( order_clause )
end

#shortcutObject

GET /by/:key e.g /by/guiness /by/ottakringer



29
30
31
32
# File 'app/controllers/beer_db_admin/breweries_controller.rb', line 29

def shortcut
  @brewery = Brewery.find_by_key!( params[:key] )
  render :show
end

#showObject

GET /breweries/:id e.g. /breweries/1



24
25
26
# File 'app/controllers/beer_db_admin/breweries_controller.rb', line 24

def show
  @brewery = Brewery.find( params[:id] )
end