diff --git a/app/models/user.rb b/app/models/user.rb index b89adaa33..bba8e9027 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,7 @@ class User < ActiveRecord::Base + extend FriendlyId + friendly_id :username, use: :slugged + # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable diff --git a/db/schema.rb b/db/schema.rb index 97db06757..b3037477b 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 => 20121027035231) do +ActiveRecord::Schema.define(:version => 20121106101936) do create_table "crops", :force => true do |t| t.string "system_name", :null => false @@ -45,11 +45,13 @@ ActiveRecord::Schema.define(:version => 20121027035231) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.string "username" + t.string "slug" end add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + add_index "users", ["slug"], :name => "index_users_on_slug", :unique => true add_index "users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 018e0c3b3..19611123a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -18,6 +18,7 @@ describe 'user' do @user2 = User.find_by_email('example@example.com') @user2.email.should == "example@example.com" @user2.username.should == "someone" + @user2.slug.should == "someone" @user2.encrypted_password.should_not be_nil end