Class: NamesController

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

Overview

Schema Information

Table name: names

id          :integer          not null, primary key
first_name  :string
middle_name :string
last_name   :string
language_id :integer
profile_id  :integer
position    :integer
created_at  :datetime         not null
updated_at  :datetime         not null

Instance Method Summary collapse

Instance Method Details

#createObject

POST /names


39
40
41
42
43
44
45
46
47
# File 'app/controllers/names_controller.rb', line 39

def create
  @name = Name.new(name_params)

  if @name.save
    redirect_to @name, notice: 'Name was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /names/1


59
60
61
62
# File 'app/controllers/names_controller.rb', line 59

def destroy
  @name.destroy
  redirect_to names_url, notice: 'Name was successfully destroyed.'
end

#editObject

GET /names/1/edit


35
36
# File 'app/controllers/names_controller.rb', line 35

def edit
end

#indexObject

GET /names


21
22
23
# File 'app/controllers/names_controller.rb', line 21

def index
  @names = Name.paginate(params[:page])
end

#newObject

GET /names/new


30
31
32
# File 'app/controllers/names_controller.rb', line 30

def new
  @name = Name.new
end

#showObject

GET /names/1


26
27
# File 'app/controllers/names_controller.rb', line 26

def show
end

#updateObject

PATCH/PUT /names/1


50
51
52
53
54
55
56
# File 'app/controllers/names_controller.rb', line 50

def update
  if @name.update(name_params)
    redirect_to @name, notice: 'Name was successfully updated.'
  else
    render :edit
  end
end