Hello , I am a ROR beginner. I have a controller named "users" and the corresponding view,model created using the command "ruby script/generate scaffold user name:string".By running the command rake db:migrate will create the table "users" with a field "name" and the migration file created automatically is "001_create_users.rb". Now when I tried to add one more column "password" ,by creating a new migration file using the command "ruby script/generate migration create_users" an error is occuring like "Another file named 001_create_users.rb already exists". May any one let me know what is the problem? I am using the right way or not? Thanks in advance Indu -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Once a migration is created with the scaffold command it cannot be altered with the scaffold command. Only manually. However, once a migration file has been used by running rake db:migrate, you are not recommended to alter this file in a real production site, but rather you must make a new migration file, but not using scaffold: script/generate migration AddPasswordColumn This command would create a new migration file where you can add/alter/ delete database columns and schema. However, if you are testing and want to redo your first scaffold command: rake db:migrate VERSION=0 And now edit the file and rerun: rake db:migrate Hank On Nov 26, 6:51 am, Indu RS <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello , > > I am a ROR beginner. I have a controller named "users" and the > corresponding view,model created using the command "ruby script/generate > scaffold user name:string".By running the command rake db:migrate will > create the table "users" with a field "name" and the migration file > created automatically is "001_create_users.rb". Now when I tried to add > one more column "password" ,by creating a new migration file using the > command "ruby script/generate migration create_users" an error is > occuring > like "Another file named 001_create_users.rb already exists". May any > one let me know what is the problem? I am using the right way or not? > > Thanks in advance > Indu > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you for your response and solved my issue -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Indu Did u start the project? After running script/generate migration AddPasswordColumn you can do like In self.up add_column :users,:password, :string and may write in self.down (only if needed) remove_column :users, :password Then as usual rake db:migrate Sijo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sijo Kg wrote:> Hi Indu > Did u start the project? > After running script/generate migration AddPasswordColumn you can do > like > In self.up > add_column :users,:password, :string > > and may write in self.down (only if needed) > > remove_column :users, :password > > Then as usual rake db:migrate > > SijoThank u Sijo. Just trying on it. Any idea of saving the encoded password into the database.? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Suppose there is a User model So in the view you have <%= password_field ''user'', ''password'' %></p> Now write in User model before_create :protect_password def protect_password self.password = Digest::MD5.hexdigest(self.password) end There may be also other ways for doing this Sijo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sijo Kg wrote:> Hi > Suppose there is a User model So in the view you have > > <%= password_field ''user'', ''password'' %></p> > Now write in User model > > before_create :protect_password > def protect_password > self.password = Digest::MD5.hexdigest(self.password) > end > > There may be also other ways for doing this > > SijoThank you so much for your help. I tried this one and can save the encrypted password. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---