Class: OrderListsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- OrderListsController
- Defined in:
- app/controllers/order_lists_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /order_lists POST /order_lists.json.
-
#destroy ⇒ Object
DELETE /order_lists/1 DELETE /order_lists/1.json.
-
#edit ⇒ Object
GET /order_lists/1/edit.
-
#index ⇒ Object
GET /order_lists GET /order_lists.json.
-
#new ⇒ Object
GET /order_lists/new GET /order_lists/new.json.
-
#show ⇒ Object
GET /order_lists/1 GET /order_lists/1.json.
-
#update ⇒ Object
PUT /order_lists/1 PUT /order_lists/1.json.
Instance Method Details
#create ⇒ Object
POST /order_lists POST /order_lists.json
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/order_lists_controller.rb', line 51 def create @order_list = OrderList.new(order_list_params) @order_list.user = current_user respond_to do |format| if @order_list.save format.html { redirect_to @order_list, notice: t('controller.successfully_created', model: t('activerecord.models.order_list')) } format.json { render json: @order_list, status: :created, location: @order_list } else format.html { render action: "new" } format.json { render json: @order_list.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /order_lists/1 DELETE /order_lists/1.json
91 92 93 94 95 96 97 98 |
# File 'app/controllers/order_lists_controller.rb', line 91 def destroy @order_list.destroy respond_to do |format| format.html { redirect_to order_lists_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /order_lists/1/edit
43 44 45 46 47 |
# File 'app/controllers/order_lists_controller.rb', line 43 def edit if params[:mode] == 'order' @order_list.edit_mode = 'order' end end |
#index ⇒ Object
GET /order_lists GET /order_lists.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/order_lists_controller.rb', line 9 def index if @bookstore @order_lists = @bookstore.order_lists.page(params[:page]) else @order_lists = OrderList.page(params[:page]) end respond_to do |format| format.html # index.html.erb format.json { render json: @order_lists } format.rss { render layout: false } format.atom end end |
#new ⇒ Object
GET /order_lists/new GET /order_lists/new.json
35 36 37 38 39 40 |
# File 'app/controllers/order_lists_controller.rb', line 35 def new respond_to do |format| format.html # new.html.erb format.json { render json: @order_list } end end |
#show ⇒ Object
GET /order_lists/1 GET /order_lists/1.json
26 27 28 29 30 31 |
# File 'app/controllers/order_lists_controller.rb', line 26 def show respond_to do |format| format.html # show.html.erb format.json { render json: @order_list } end end |
#update ⇒ Object
PUT /order_lists/1 PUT /order_lists/1.json
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/order_lists_controller.rb', line 69 def update respond_to do |format| if @order_list.update_attributes(order_list_params) if @order_list.edit_mode == 'order' @order_list.transition_to(:ordered) @order_list.save(validate: false) format.html { redirect_to purchase_requests_url(order_list_id: @order_list.id), notice: t('controller.successfully_updated', model: t('activerecord.models.order_list')) } else format.html { redirect_to @order_list , notice: t('controller.successfully_updated', model: t('activerecord.models.order_list')) } end format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @order_list.errors, status: :unprocessable_entity } end end end |