From a752706acdb1df4a2014ef90c611ff034ffe3259 Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Fri, 14 Oct 2011 12:14:16 -0700 Subject: [PATCH] user name --- app/models/user.rb | 4 +++- app/views/devise/registrations/edit.html.erb | 6 ++++++ app/views/devise/registrations/new.html.erb | 6 ++++++ db/migrate/20111014181801_add_names_to_users.rb | 6 ++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20111014181801_add_names_to_users.rb diff --git a/app/models/user.rb b/app/models/user.rb index 7ad789b..00a3dcb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,9 +10,11 @@ class User < ActiveRecord::Base :validatable, :confirmable, :lockable + + validates :first_name, :last_name, :presence => true # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me + attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name has_many :records end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index b1b1bdb..a464d6d 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -9,6 +9,12 @@ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> <%= devise_error_messages! %> +
<%= f.label :first_name %>
+ <%= f.text_field :first_name %>
+ +
<%= f.label :last_name %>
+ <%= f.text_field :last_name %>
+
<%= f.label :email %>
<%= f.email_field :email %>
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 2b03b47..d9ca1cf 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -7,6 +7,12 @@ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> +
<%= f.label :first_name %>
+ <%= f.text_field :first_name %>
+ +
<%= f.label :last_name %>
+ <%= f.text_field :last_name %>
+
<%= f.label :email %>
<%= f.email_field :email %>
diff --git a/db/migrate/20111014181801_add_names_to_users.rb b/db/migrate/20111014181801_add_names_to_users.rb new file mode 100644 index 0000000..3620812 --- /dev/null +++ b/db/migrate/20111014181801_add_names_to_users.rb @@ -0,0 +1,6 @@ +class AddNamesToUsers < ActiveRecord::Migration + def change + add_column :users, :first_name, :string #, :null => false + add_column :users, :last_name, :string #, :null => false + end +end