| 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 | class RoutesController < ChouetteController
  defaults :resource_class => Chouette::Route
  respond_to :html, :xml, :json
  respond_to :kml, :only => :show
  belongs_to :referential do
    belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true
  end
  def index     
    index! do |format|
      format.html { redirect_to referential_line_path(@referential,@line) }
    end
  end
  def show
    @map = RouteMap.new(route).with_helpers(self)
    @stop_points = route.stop_points.paginate(:page => params[:page], :per_page => 10)
    show!
  end
  def destroy
    destroy! do |success, failure|
      success.html { redirect_to referential_line_path(@referential,@line) }
    end
  end
  def create
    create! do |success, failure|
      success.html { redirect_to referential_line_path(@referential,@line) }
    end
  end
  def update
    update! do |success, failure|
      success.html { redirect_to referential_line_path(@referential,@line) }
    end
  end
  protected
  alias_method :route, :resource
  def collection
    @q = parent.routes.search(params[:q])
    @routes ||= 
      begin
        routes = @q.result(:distinct => true).order(:name)
        routes = routes.paginate(:page => params[:page], :per_page => @per_page) if @per_page.present?
        routes
      end
  end
end
 |