Class: RealizesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/realizes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /realizes POST /realizes.json



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/realizes_controller.rb', line 55

def create
  @realize = Realize.new(realize_params)

  respond_to do |format|
    if @realize.save
      format.html { redirect_to @realize, notice: t('controller.successfully_created', model: t('activerecord.models.realize')) }
      format.json { render json: @realize, status: :created, location: @realize }
    else
      prepare_options
      format.html { render action: "new" }
      format.json { render json: @realize.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /realizes/1 DELETE /realizes/1.json



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'app/controllers/realizes_controller.rb', line 94

def destroy
  @realize.destroy

  respond_to do |format|
    format.html {
      flash[:notice] = t('controller.successfully_deleted', model: t('activerecord.models.realize'))
      case
      when @expression
        redirect_to expression_agents_url(@expression)
      when @agent
        redirect_to agent_expressions_url(@agent)
      else
        redirect_to realizes_url
      end
    }
    format.json { head :no_content }
  end
end

#editObject

GET /realizes/1/edit



50
51
# File 'app/controllers/realizes_controller.rb', line 50

def edit
end

#indexObject

GET /realizes GET /realizes.json



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/realizes_controller.rb', line 9

def index
  case
  when @agent
    @realizes = @agent.realizes.order('realizes.position').page(params[:page])
  when @expression
    @realizes = @expression.realizes.order('realizes.position').page(params[:page])
  else
    @realizes = Realize.page(params[:page])
  end

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @realizes }
  end
end

#newObject

GET /realizes/new



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/realizes_controller.rb', line 35

def new
  if @expression && @agent.blank?
    redirect_to expression_agents_url(@expression)
    return
  elsif @agent && @expression.blank?
    redirect_to agent_expressions_url(@agent)
    return
  else
    @realize = Realize.new
    @realize.expression = @expression
    @realize.agent = @agent
  end
end

#showObject

GET /realizes/1 GET /realizes/1.json



27
28
29
30
31
32
# File 'app/controllers/realizes_controller.rb', line 27

def show
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @realize }
  end
end

#updateObject

PUT /realizes/1 PUT /realizes/1.json



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/controllers/realizes_controller.rb', line 72

def update
  # 並べ替え
  if @expression && params[:move]
    move_position(@realize, params[:move], false)
    redirect_to realizes_url(expression_id: @realize.expression_id)
    return
  end

  respond_to do |format|
    if @realize.update(realize_params)
      format.html { redirect_to @realize, notice: t('controller.successfully_updated', model: t('activerecord.models.realize')) }
      format.json { head :no_content }
    else
      prepare_options
      format.html { render action: "edit" }
      format.json { render json: @realize.errors, status: :unprocessable_entity }
    end
  end
end