blob: 447c48bc3536965e11a91244b042ebfb1265bebb (
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
31
 | class ReferentialsController < InheritedResources::Base
  respond_to :html
  respond_to :json, :only => :show
  respond_to :js, :only => :show
  
  def show 
     resource.switch
     show! do |format|
       format.json {
         render :json => { :lines_count => resource.lines.count,
                :networks_count => resource.networks.count,
                :vehicle_journeys_count => resource.vehicle_journeys.count,
                :time_tables_count => resource.time_tables.count,
                :referential_id => resource.id}
       }
     end
  end
  
  protected
  def resource
    @referential ||= current_organisation.referentials.find_by_id(params[:id])
  end
  def collection    
    @referentials ||= current_organisation.referentials
  end
  def create_resource(referential)
    referential.organisation = current_organisation
    super
  end
    
end
 |