OSDN Git Service

5c2d2b2dad93981ac4520cff6daee12f822beca5
[tdcgexplorer/nimono.git] / app / controllers / arcs_controller.rb
1 class ArcsController < ApplicationController
2   include AuthenticatedSystem
3   layout 'arcs'
4   before_filter :login_required, :only => [ :new, :edit, :create, :update, :destroy ]
5
6   # GET /arcs
7   # GET /arcs.xml
8   def index
9     @search = Arc::Search.new(params[:search])
10     @arcs = Arc.paginate(@search.find_options.merge(:page => params[:page], :order => 'location_id, code', :include => :location))
11
12     respond_to do |format|
13       format.html # index.html.erb
14       format.xml  { render :xml => @arcs }
15     end
16   end
17
18   # GET /arcs/1
19   # GET /arcs/1.xml
20   def show
21     @arc = Arc.find(params[:id])
22
23     respond_to do |format|
24       format.html # show.html.erb
25       format.xml  { render :xml => @arc }
26     end
27   end
28
29   # GET /arcs/new
30   # GET /arcs/new.xml
31   def new
32     @arc = Arc.new
33
34     respond_to do |format|
35       format.html # new.html.erb
36       format.xml  { render :xml => @arc }
37     end
38   end
39
40   # GET /arcs/1/edit
41   def edit
42     @arc = Arc.find(params[:id])
43   end
44
45   # POST /arcs
46   # POST /arcs.xml
47   def create
48     @arc = Arc.new(params[:arc])
49
50     respond_to do |format|
51       if @arc.save
52         flash[:notice] = 'Arc was successfully created.'
53         format.html { redirect_to(@arc) }
54         format.xml  { render :xml => @arc, :status => :created, :location => @arc }
55       else
56         format.html { render :action => "new" }
57         format.xml  { render :xml => @arc.errors, :status => :unprocessable_entity }
58       end
59     end
60   end
61
62   # PUT /arcs/1
63   # PUT /arcs/1.xml
64   def update
65     @arc = Arc.find(params[:id])
66
67     respond_to do |format|
68       if @arc.update_attributes(params[:arc])
69         flash[:notice] = 'Arc was successfully updated.'
70         format.html { redirect_to(@arc) }
71         format.xml  { head :ok }
72       else
73         format.html { render :action => "edit" }
74         format.xml  { render :xml => @arc.errors, :status => :unprocessable_entity }
75       end
76     end
77   end
78
79   # DELETE /arcs/1
80   # DELETE /arcs/1.xml
81   def destroy
82     @arc = Arc.find(params[:id])
83     @arc.destroy
84
85     respond_to do |format|
86       format.html { redirect_to(arcs_url) }
87       format.xml  { head :ok }
88     end
89   end
90 end