Browse Source

user name

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
a752706acd
  1. 4
      app/models/user.rb
  2. 6
      app/views/devise/registrations/edit.html.erb
  3. 6
      app/views/devise/registrations/new.html.erb
  4. 6
      db/migrate/20111014181801_add_names_to_users.rb

4
app/models/user.rb

@ -11,8 +11,10 @@ class User < ActiveRecord::Base
:confirmable, :confirmable,
:lockable :lockable
validates :first_name, :last_name, :presence => true
# Setup accessible (or protected) attributes for your model # 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 has_many :records
end end

6
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| %> <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %> <%= devise_error_messages! %>
<div><%= f.label :first_name %><br />
<%= f.text_field :first_name %></div>
<div><%= f.label :last_name %><br />
<%= f.text_field :last_name %></div>
<div><%= f.label :email %><br /> <div><%= f.label :email %><br />
<%= f.email_field :email %></div> <%= f.email_field :email %></div>

6
app/views/devise/registrations/new.html.erb

@ -7,6 +7,12 @@
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %> <%= devise_error_messages! %>
<div><%= f.label :first_name %><br />
<%= f.text_field :first_name %></div>
<div><%= f.label :last_name %><br />
<%= f.text_field :last_name %></div>
<div><%= f.label :email %><br /> <div><%= f.label :email %><br />
<%= f.email_field :email %></div> <%= f.email_field :email %></div>

6
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
Loading…
Cancel
Save