Class: DemandsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- DemandsController
- Defined in:
- app/controllers/demands_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /demands POST /demands.json.
-
#destroy ⇒ Object
DELETE /demands/1 DELETE /demands/1.json.
-
#edit ⇒ Object
GET /demands/1/edit.
-
#index ⇒ Object
GET /demands GET /demands.json.
-
#new ⇒ Object
GET /demands/new GET /demands/new.json.
-
#show ⇒ Object
GET /demands/1 GET /demands/1.json.
-
#update ⇒ Object
PUT /demands/1 PUT /demands/1.json.
Instance Method Details
#create ⇒ Object
POST /demands POST /demands.json
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/demands_controller.rb', line 42 def create @demand = Demand.new(demand_params) respond_to do |format| if @demand.save format.html { redirect_to @demand, notice: t('statistic.successfully_created', model: t('activerecord.models.demand')) } format.json { render json: @demand, status: :created, location: @demand } else format.html { render action: "new" } format.json { render json: @demand.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /demands/1 DELETE /demands/1.json
72 73 74 75 76 77 78 79 |
# File 'app/controllers/demands_controller.rb', line 72 def destroy @demand.destroy respond_to do |format| format.html { redirect_to demands_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /demands/1/edit
37 38 |
# File 'app/controllers/demands_controller.rb', line 37 def edit end |
#index ⇒ Object
GET /demands GET /demands.json
6 7 8 9 10 11 12 13 |
# File 'app/controllers/demands_controller.rb', line 6 def index @demands = Demand.order('id DESC').page(params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @demands } end end |
#new ⇒ Object
GET /demands/new GET /demands/new.json
27 28 29 30 31 32 33 34 |
# File 'app/controllers/demands_controller.rb', line 27 def new @demand = Demand.new respond_to do |format| format.html # new.html.erb format.json { render json: @demand } end end |
#show ⇒ Object
GET /demands/1 GET /demands/1.json
17 18 19 20 21 22 23 |
# File 'app/controllers/demands_controller.rb', line 17 def show respond_to do |format| format.html # show.html.erb format.json { render json: @demand } format.txt end end |
#update ⇒ Object
PUT /demands/1 PUT /demands/1.json
58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/demands_controller.rb', line 58 def update respond_to do |format| if @demand.update_attributes(demand_params) format.html { redirect_to @demand, notice: t('controller.successfully_updated', model: t('activerecord.models.demand')) } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @demand.errors, status: :unprocessable_entity } end end end |