aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/lines_controller.rb
blob: e14baf2116f4e50dba3470ee2229342cfbda7e82 (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
class LinesController < ChouetteController
  defaults :resource_class => Chouette::Line
  respond_to :html
  respond_to :xml
  respond_to :json

  belongs_to :referential

  def show
    @map = LineMap.new referential, resource
    @routes = @line.routes
    show!
  end

  def destroy_all
    objects =
      get_collection_ivar || set_collection_ivar(end_of_association_chain.where(:id => params[:ids]))
    objects.destroy_all
    respond_with(objects, :location => smart_collection_url)
  end

  protected

  def collection
    @q = referential.lines.search(params[:q])
    @lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page], :per_page => 10).includes([:network, :company])
  end

end