diff --git a/app/models/user.rb b/app/models/user.rb index 02543cc..c7bb5cc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,6 +6,6 @@ class User < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me + attr_accessible :email, :password, :password_confirmation, :remember_me, :username # attr_accessible :title, :body end diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index f9bc2c1..3d526fb 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,8 +1,8 @@

Sign in

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> -
<%= f.label :email %>
- <%= f.email_field :email, :autofocus => true %>
+
<%= f.label :username %>
+ <%= f.text_field :username, :autofocus => true %>
<%= f.label :password %>
<%= f.password_field :password %>
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index c455f22..d4445de 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -23,7 +23,7 @@ Devise.setup do |config| # session. If you need permissions, you should implement that in a before filter. # You can also supply a hash where the value is a boolean determining whether # or not authentication should be aborted when the value is not present. - # config.authentication_keys = [ :email ] + config.authentication_keys = [ :username ] # Configure parameters from the request object used for authentication. Each entry # given should be a request method and it will automatically be passed to the diff --git a/db/migrate/20130413054153_add_username_to_users.rb b/db/migrate/20130413054153_add_username_to_users.rb new file mode 100644 index 0000000..3b71a27 --- /dev/null +++ b/db/migrate/20130413054153_add_username_to_users.rb @@ -0,0 +1,5 @@ +class AddUsernameToUsers < ActiveRecord::Migration + def change + add_column :users, :username, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 5c80be9..41b8f56 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130412012722) do +ActiveRecord::Schema.define(:version => 20130413054153) do create_table "alerts", :force => true do |t| t.integer "user_id" @@ -55,6 +55,7 @@ ActiveRecord::Schema.define(:version => 20130412012722) do t.string "last_sign_in_ip" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.string "username" end add_index "users", ["email"], :name => "index_users_on_email", :unique => true