Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
add last anf first name to user
Browse files Browse the repository at this point in the history
  • Loading branch information
PanfilovDenis committed Feb 6, 2013
1 parent 69c941f commit 167c93b
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class User < ActiveRecord::Base
include UserRepository

attr_accessible :email, :password, :password_digest,
:name, :city,
:first_name, :last_name, :city,
:company, :position,
:show_as_participant, :photo, :state_event, :about

Expand All @@ -22,11 +22,11 @@ class User < ActiveRecord::Base
end

def full_name
name
"#{last_name} #{first_name}"
end

def to_s
name
full_name
end

end
3 changes: 2 additions & 1 deletion app/types/user_edit_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ class UserEditType < User
has_secure_password

validates :email, presence: true, uniqueness: true
validates :name, presence: true
validates :first_name, presence: true
validates :last_name, presence: true
end
3 changes: 2 additions & 1 deletion app/views/web/account/accounts/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
= f.input :email
= f.input :password
= f.input :password_confirmation
= f.input :name
= f.input :first_name
= f.input :last_name
= f.input :city
= f.input :company
= f.input :show_as_participant
Expand Down
3 changes: 2 additions & 1 deletion app/views/web/admin/users/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
.row
.span4
= f.input :state_event, :as => :state_event
= f.input :name
= f.input :first_name
= f.input :last_name
= f.input :city
= f.input :about, :as => :text, :input_html => { :cols => 50, :rows => 3 }
.span4
Expand Down
2 changes: 1 addition & 1 deletion app/views/web/admin/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%thead
%tr
%th= User.human_attribute_name :id
%th= User.human_attribute_name :name
%th= User.human_attribute_name :first_name
%th= User.human_attribute_name :state
%th= t(".created_at")
%th= t(".actions")
Expand Down
3 changes: 2 additions & 1 deletion app/views/web/admin/users/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
.row
.span4
= f.input :state_event, :as => :state_event
= f.input :name
= f.input :first_name
= f.input :last_name
= f.input :city
= f.input :company
= f.input :about, :as => :text, :input_html => { :cols => 50, :rows => 3 }
Expand Down
2 changes: 1 addition & 1 deletion app/views/web/admin/users/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%strong= User.human_attribute_name :id
%br= @user.id

%strong= User.human_attribute_name :name
%strong= User.human_attribute_name :first_name
%br= @user.full_name

%strong= User.human_attribute_name :state
Expand Down
6 changes: 5 additions & 1 deletion app/views/web/users/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
= simple_form_for @user do |f|
.row-fluid
.span4
= f.input :name
= f.input :first_name

.span4
= f.input :last_name

.span4
= f.input :company

.row-fluid
.span4
= f.input :position

Expand Down
4 changes: 2 additions & 2 deletions app/views/web/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
%table.table.table-striped
%thead
%tr
%th= User.human_attribute_name :name
%th= User.human_attribute_name :first_name
%th= User.human_attribute_name :city
%th= User.human_attribute_name :company
%th= User.human_attribute_name :position
%tbody
- @users.each do |user|
%tr
%td= user.name
%td= user
%td= user.city
%td= user.company
%td= user.position
Expand Down
3 changes: 2 additions & 1 deletion config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ ru:

user:
email: "Email"
name: "ФИО"
first_name: "Имя"
last_name: "Фамилия"
password: "Пароль"
password_confirmation: "Подтверждение пароля"
city: "Город"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddLastNameAndFirstNameToUser < ActiveRecord::Migration
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
end
end
5 changes: 5 additions & 0 deletions db/migrate/20130206103351_remove_name_from_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveNameFromUser < ActiveRecord::Migration
def change
remove_column :users, :name
end
end
7 changes: 4 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130205071630) do
ActiveRecord::Schema.define(:version => 20130206103351) do

create_table "ckeditor_assets", :force => true do |t|
t.string "data_file_name", :null => false
Expand Down Expand Up @@ -50,16 +50,17 @@
t.string "password_digest"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name"
t.string "city"
t.string "company"
t.boolean "show_as_participant"
t.string "position"
t.boolean "admin"
t.string "password"
t.string "state"
t.string "photo"
t.string "state"
t.text "about"
t.string "first_name"
t.string "last_name"
end

end
2 changes: 1 addition & 1 deletion test/factories/sequences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"email_#{n}@mail.com"
end

[:name, :city, :company,
[:first_name, :last_name, :city, :company,
:slug, :title, :body, :photo].each do |trait|

sequence trait do |n|
Expand Down
3 changes: 2 additions & 1 deletion test/factories/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

factory :user, :class => UserEditType do
password "sekret"
name
first_name
last_name
city
company
show_as_participant
Expand Down

0 comments on commit 167c93b

Please sign in to comment.