aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/lines_controller.rb
blob: a5be8ca449cf9437c96b280ca0e4dfef390c4400 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class LinesController < ChouetteController
  defaults :resource_class => Chouette::Line
  helper_method :sort_column, :sort_direction
  respond_to :html
  respond_to :xml
  respond_to :json

  protected

  def collection
    @lines ||= referential.lines.order_by [[sort_column.to_sym, sort_direction.to_sym]]
  end

  def sort_column  
    %w(name number).include?(params[:sort]) ? params[:sort] : "name"
  end  
    
  def sort_direction  
    %w(asc desc).include?(params[:direction]) ? params[:direction] : "asc"
  end  

  def resource_url(line = nil)
    referential_line_path(referential, line || resource)
  end

  def collection_url
    referential_lines_path(referential)
  end

end