Module: Paramount::Controller

Defined in:
lib/paramount/controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
# File 'lib/paramount/controller.rb', line 18

def create
  new

  if new.form(resource_params).save
    redirection(action: 'created')
  else
    render :new
  end
end

#destroyObject



36
37
38
39
# File 'lib/paramount/controller.rb', line 36

def destroy
  resource.destroy
  redirect_to polymorphic_path(resource.class), notice: 'Successfully destroyed'
end

#editObject



14
15
16
# File 'lib/paramount/controller.rb', line 14

def edit
  resource
end

#indexObject



3
4
5
# File 'lib/paramount/controller.rb', line 3

def index
  collection
end

#newObject



11
12
# File 'lib/paramount/controller.rb', line 11

def new
end

#showObject



7
8
9
# File 'lib/paramount/controller.rb', line 7

def show
  resource
end

#updateObject



28
29
30
31
32
33
34
# File 'lib/paramount/controller.rb', line 28

def update
  if resource.form(resource_params).save
    redirection(action: 'updated')
  else
    render :edit
  end
end