Class: Wf::FieldsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wf/fields_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#wf_current_user

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/wf/fields_controller.rb', line 15

def create
  @form = Wf::Form.find(params[:form_id])
  @field = @form.fields.new(field_params)
  if @field.save
    redirect_to form_path(@form), notice: "field was successfully created."
  else
    render :new
  end
end

#destroyObject



25
26
27
28
29
30
# File 'app/controllers/wf/fields_controller.rb', line 25

def destroy
  @form = Wf::Form.find(params[:form_id])
  @field = @form.fields.find(params[:id])
  @field.destroy
  render js: "window.location.reload()"
end

#editObject



32
33
34
35
36
# File 'app/controllers/wf/fields_controller.rb', line 32

def edit
  @form = Wf::Form.find(params[:form_id])
  @field = @form.fields.find(params[:id])
  breadcrumb @form.name, form_path(@form)
end

#newObject



9
10
11
12
13
# File 'app/controllers/wf/fields_controller.rb', line 9

def new
  @form = Wf::Form.find(params[:form_id])
  @field = @form.fields.new
  breadcrumb @form.name, form_path(@form)
end

#updateObject



38
39
40
41
42
43
44
45
46
# File 'app/controllers/wf/fields_controller.rb', line 38

def update
  @form = Wf::Form.find(params[:form_id])
  @field = @form.fields.find(params[:id])
  if @field.update(field_params)
    redirect_to form_path(@form), notice: "field was successfully created."
  else
    render :edit
  end
end