A step on how to add migration development to an existing user model in ruby ​​on rails?

I have already created a user model. I am wondering how can I customize the application with my existing user model. In doing so, I need to configure any additional routes or make atttributes available in my custom method.

While the user model

class User < ActiveRecord::Base attr_accessible :email, :pic, :name, :username has_many :topics end 

My migration for CreateUsers

 class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.string :email t.string :username t.string :pic t.timestamps end end end 

Now i plan to run

 rails g migration AddDeviseColumnsToUser 

And add this to my migration file

 class AddDeviseColumnsToUser < ActiveRecord::Migration def change change_table :users do |t| t.string :encrypted_password, :null => false, :default => '', :limit => 128 t.confirmable t.recoverable t.rememberable t.trackable t.token_authenticatable t.timestamps end end end 

Now I'm wondering how do I set up routes or do I need to? And what attributes should be available in my User model?

Update: I already installed Devise and configured it using

 rails generate devise:install 
+7
source share
2 answers

Just add devise_for :user to your routes

Add attr_accessible :password, :password_confirmation

and for more information take a look at a typical development model

https://github.com/johndel/Rails-Simple-CMS/blob/master/app/models/admin.rb

(Pretty simple)

+9
source

You can simply run:

 rails generate devise User 

add user model design.

+4
source

All Articles