diff options
| author | Luc Donnet | 2012-01-09 17:57:51 +0100 |
|---|---|---|
| committer | Luc Donnet | 2012-01-09 17:57:51 +0100 |
| commit | a4eeeeaa4b7b199e5b4e41c61c33e5a56fccc823 (patch) | |
| tree | fb6d934cb44518c7b04b87e4f4886efd36fcfa58 /app/controllers | |
| parent | d9dd47206fe11e6b2400ed93407fc50521fa10dd (diff) | |
| download | chouette-core-a4eeeeaa4b7b199e5b4e41c61c33e5a56fccc823.tar.bz2 | |
Add locales and views for lines
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/lines_controller.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 3a986b27c..83ab01674 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -1,4 +1,24 @@ class LinesController < InheritedResources::Base defaults :resource_class => Chouette::Line + helper_method :sort_column, :sort_direction + respond_to :html + respond_to :xml + respond_to :json + + protected + + def collection + @lines ||= Chouette::Line.all.order_by [[sort_column.to_sym, sort_direction.to_sym]] + end + + private + + 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 end |
