OSDN Git Service

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