Ok I have been trying to get started with Ruby on Rails and I want to tie it together with a mysql database. I have been using the examples in teh Agile Web Developkent with Rails, which has you setup the database.yml file and run rake db:migrate to make sure you can connect. Well this all works great. Next you create a model using script/generate model Account Once this is created if you run rake db:migrate it will fail. Giving you an unitialized constant CreateAccount error. After doing some research online it appears the the file that is generated is named wrong and that is much exactly match the name of the class definition inside the migration file. The generated file is 001_create_accounts.rb /************ Migration File 001_create_accounts.rb class CreateAccounts < ActiveRecord::Migration def self.up create_table :accounts do |t| end end def self.down drop_table :accounts end end /************************* I renamed the file to 001_CreateAccounts.rb, however now I get this : vincent-cordaros-computer:~/Development/WorkSpace/rails/mymeetingstone Storm$ rake db:migrate -- trace (in /Users/Storm/Development/WorkSpace/rails/mymeetingstone) ******************************************************************* * config.breakpoint_server has been deprecated and has no effect. * ******************************************************************* rake aborted! You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.first Anyone have any ideas or can point me to a good working code example. I just really want to leverage the object relational mapping of Rails. --~--~---------~--~----~------------~-------~--~----~ 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 Do you know anyone who would be interested in a Ruby on Rails Developer role in UK, Leicester? Thank you Ferdouse -- 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 -~----------~----~----~----~------~----~------~--~---
Vince wrote:> Ok I have been trying to get started with Ruby on Rails and I want to > tie it together with a mysql database. I have been using the > examples in teh Agile Web Developkent with Rails, which has you setup > the database.yml file and run rake db:migrate to make sure you can > connect. > > Well this all works great. > > Next you create a model using script/generate model Account > > Once this is created if you run rake db:migrate it will fail. Giving > you an unitialized constant CreateAccount error. > > After doing some research online it appears the the file that is > generated is named wrong and that is much exactly match the name of > the class definition inside the migration file. > The generated file is 001_create_accounts.rb > > > /************ Migration File 001_create_accounts.rb > class CreateAccounts < ActiveRecord::Migration > def self.up > create_table :accounts do |t| > end > end > > def self.down > drop_table :accounts > end > end > > /************************* >The generated filename is correct, and it looks right to me. My first suspicion was that you were migrating an empty table, but I just tried and that works for me. The error you''re getting doesn''t really suggest a DB problem to me, it suggests some other problem with your rails setup. How did you install Rails? following the instructions at rubyonrails.org? or are you using Instant Rails? Or if you''re on linux, did you use a package manager? -- http://www.5valleys.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 you migrate the db(rake db:migrate), you can''t rename the migration or add anything to it. You have to generate a new migration, script/generate model Accounts, then db:migrate and it should work. On Jun 27, 8:15 am, Jon Garvin <jgarvin.li...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Vince wrote: > > Ok I have been trying to get started with Ruby on Rails and I want to > > tie it together with a mysql database. I have been using the > > examples in teh Agile Web Developkent with Rails, which has you setup > > the database.yml file and run rake db:migrate to make sure you can > > connect. > > > Well this all works great. > > > Next you create a model using script/generate model Account > > > Once this is created if you run rake db:migrate it will fail. Giving > > you an unitialized constant CreateAccount error. > > > After doing some research online it appears the the file that is > > generated is named wrong and that is much exactly match the name of > > the class definition inside the migration file. > > The generated file is 001_create_accounts.rb > > > /************ Migration File 001_create_accounts.rb > > class CreateAccounts < ActiveRecord::Migration > > def self.up > > create_table :accounts do |t| > > end > > end > > > def self.down > > drop_table :accounts > > end > > end > > > /************************* > > The generated filename is correct, and it looks right to me. My first > suspicion was that you were migrating an empty table, but I just tried > and that works for me. The error you''re getting doesn''t really suggest > a DB problem to me, it suggests some other problem with your rails > setup. How did you install Rails? following the instructions at > rubyonrails.org? or are you using Instant Rails? Or if you''re on linux, > did you use a package manager? > > --http://www.5valleys.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 -~----------~----~----~----~------~----~------~--~---
jg wrote:> Once you migrate the db(rake db:migrate), you can''t rename the > migration or add anything to it. You have to generate a new migration, > script/generate model Accounts, then db:migrate and it should work. > >As I understand, he said it "failed" the first time, with an Uninitialized Constant error. The problem isn''t trying to rename it after running it. The problem is trying to get it to run successfully the first time. -- http://www.5valleys.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 -~----------~----~----~----~------~----~------~--~---