I''m writing an application and decided late in the game that I needed authentication, so after viewing Ryan''s railscast, I downloaded the plugin: script/plugin source http://svn.techno-weenie.net/projects/plugins/ script/plugin install restful_authentication script/generate authenticated user session rake db:migrate I''m getting the error: rake aborted! Mysql::Error: Table ''users'' already exists: CREATE TABLE users (''id'' int(11) DEFAULT NULL auto_increment PRIMARY KEY) ENGINE=InnoDB What''s the best way to fix this. Will it work to just migrate back to version=0 and delete the migration files having to do with a users table I tried to create on my own in the beginning? or will that just blow everything up? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Judy Johnson wrote:> I''m writing an application and decided late in the game that I needed > authentication, so after viewing Ryan''s railscast, I downloaded the > plugin: > script/plugin source http://svn.techno-weenie.net/projects/plugins/ > script/plugin install restful_authentication > script/generate authenticated user session > rake db:migrate > > I''m getting the error: rake aborted! > Mysql::Error: Table ''users'' already exists: CREATE TABLE users (''id'' > int(11) DEFAULT NULL auto_increment PRIMARY KEY) ENGINE=InnoDB > > What''s the best way to fix this. Will it work to just migrate back to > version=0 and delete the migration files having to do with a users > table I tried to create on my own in the beginning? or will that just > blow everything up?I''m a newbie, so my advice should be considered carefully, but I do know that if you include ":force => true do |t|" after the create_table statement (see below), it will basically write over the existing one: create_table :users, :force => true do |t| -- 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 -~----------~----~----~----~------~----~------~--~---
Okay, so I remembered that when I originally ran script/generate authenticated user session, that I got the message that the "09_create_users.rb" migrate file already existed. So it wasn''t overwritten with the correct file. So I went to script/plugin source http://svn.techno-weenie.net/projects/plugins/, found the correct file and did a copy and paste (inserting "users" where "<%= table_name %>" was, etc.). Now my migrate file looks like this: class CreateUsers < ActiveRecord::Migration def self.up create_table users, :force => true do |t| t.column :login, :string t.column :email, :string t.column :crypted_password, :string, :limit => 40 t.column :salt, :string, :limit => 40 t.column :created_at, :datetime t.column :updated_at, :datetime t.column :remember_token, :string t.column :remember_token_expires_at, :datetime t.column :activation_code, :string, :limit => 40 t.column :activated_at, :datetime end end def self.down drop_table users end end When I run rake db:migrate I get: Rake aborted! Undefined method ''users'' for #<ActiveRecord::ConnectionAdapters::MysqlAdapter:0x3e259d4> Now I''m really lost. I''m not sure what this error means, so I don''t know what to do. -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Denise Robinson Sent: Thursday, November 15, 2007 9:28 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: table ''users'' already exists Judy Johnson wrote:> I''m writing an application and decided late in the game that I needed > authentication, so after viewing Ryan''s railscast, I downloaded the > plugin: > script/plugin source http://svn.techno-weenie.net/projects/plugins/ > script/plugin install restful_authentication > script/generate authenticated user session > rake db:migrate > > I''m getting the error: rake aborted! > Mysql::Error: Table ''users'' already exists: CREATE TABLE users (''id'' > int(11) DEFAULT NULL auto_increment PRIMARY KEY) ENGINE=InnoDB > > What''s the best way to fix this. Will it work to just migrate back to > version=0 and delete the migration files having to do with a users > table I tried to create on my own in the beginning? or will that just > blow everything up?I''m a newbie, so my advice should be considered carefully, but I do know that if you include ":force => true do |t|" after the create_table statement (see below), it will basically write over the existing one: create_table :users, :force => true do |t| -- 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 -~----------~----~----~----~------~----~------~--~---
On 15 Nov 2007, at 14:58, Judy Johnson wrote:> def self.up > create_table users, :force => true do |t| > > def self.down > drop_table users > end > end > > When I run rake db:migrate > I get: > Rake aborted! > Undefined method ''users'' for > #<ActiveRecord::ConnectionAdapters::MysqlAdapter:0x3e259d4> > > Now I''m really lost. I''m not sure what this error means, so I don''t > know > what to do.It means there is no method or local variable called users. You''ve typoed the above, you meant to write :users and not users. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---