Class: CreatesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CreatesController
- Defined in:
- app/controllers/creates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /creates POST /creates.json.
-
#destroy ⇒ Object
DELETE /creates/1 DELETE /creates/1.json.
-
#edit ⇒ Object
GET /creates/1/edit.
-
#index ⇒ Object
GET /creates GET /creates.json.
-
#new ⇒ Object
GET /creates/new.
-
#show ⇒ Object
GET /creates/1 GET /creates/1.json.
-
#update ⇒ Object
PUT /creates/1 PUT /creates/1.json.
Instance Method Details
#create ⇒ Object
POST /creates POST /creates.json
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/creates_controller.rb', line 55 def create @create = Create.new(create_params) respond_to do |format| if @create.save format.html { redirect_to @create, notice: t('controller.successfully_created', model: t('activerecord.models.create')) } format.json { render json: @create, status: :created, location: @create } else format.html { render action: "new" } format.json { render json: @create.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /creates/1 DELETE /creates/1.json
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/controllers/creates_controller.rb', line 94 def destroy @create.destroy respond_to do |format| flash[:notice] = t('controller.successfully_deleted', model: t('activerecord.models.create')) case when @agent format.html { redirect_to agent_works_url(@agent) } format.json { head :no_content } when @work format.html { redirect_to work_agents_url(@work) } format.json { head :no_content } else format.html { redirect_to creates_url } format.json { head :no_content } end end end |
#edit ⇒ Object
GET /creates/1/edit
50 51 |
# File 'app/controllers/creates_controller.rb', line 50 def edit end |
#index ⇒ Object
GET /creates GET /creates.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/creates_controller.rb', line 9 def index case when @agent @creates = @agent.creates.order('creates.position').page(params[:page]) when @work @creates = @work.creates.order('creates.position').page(params[:page]) else @creates = Create.page(params[:page]) end respond_to do |format| format.html # index.html.erb format.json { render json: @creates } end end |
#new ⇒ Object
GET /creates/new
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/creates_controller.rb', line 35 def new if @agent && @work.blank? redirect_to agent_works_url(@patorn) return elsif @work && @agent.blank? redirect_to work_agents_url(@work) return else @create = Create.new @create.work = @work @create.agent = @agent end end |
#show ⇒ Object
GET /creates/1 GET /creates/1.json
27 28 29 30 31 32 |
# File 'app/controllers/creates_controller.rb', line 27 def show respond_to do |format| format.html # show.html.erb format.json { render json: @create } end end |
#update ⇒ Object
PUT /creates/1 PUT /creates/1.json
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/creates_controller.rb', line 72 def update # 並べ替え if @work && params[:move] move_position(@create, params[:move], false) redirect_to creates_url(work_id: @create.work_id) return end respond_to do |format| if @create.update(create_params) format.html { redirect_to @create, notice: t('controller.successfully_updated', model: t('activerecord.models.create')) } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @create.errors, status: :unprocessable_entity } end end end |