Hi guys,
I''m having problems when creating basic web applications using rails
2.2 and mySQL databases.
If I create the following table in a database named moviecritc_development:
CREATE TABLE movies (
id INT NOT NULL AUTO_INCREMENT PRIMARY_KEY,
name VARCHAR(30) NOT NULL );
and then run the following ruby commands:
rails -d mysql moviecritic (creates all the necessary files without any issue.)
I then modify the config/database.yml to include the root password to
my database and run then ruby the following ruby command:
ruby script/generate scaffold Movie (creates usual files without error).
If i now view the db/migrate.create_movies.rb i see the following:
class CreateMovies < ActiveRecord::Migration
def self.up
create_table :movies do |t|
t.timestamps
end
end
def self.down
drop_table :movies
end
end
It doesn''t make a reference to the name column i created! This is
reflected when i navigate to localhost:3000/movies/new i only see a
Back link and a Create Button, i don''t see a NAME FIELD INPUT.
Has anyone any ideas why this is happening?
Thanks in advance,
Stephen
--~--~---------~--~----~------------~-------~--~----~
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 Dec 13, 11:11 am, "Stephen Morrison" <stephen.dmorri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi guys, > I''m having problems when creating basic web applications using rails > 2.2 and mySQL databases. > If I create the following table in a database named moviecritc_development: > > CREATE TABLE movies ( > id INT NOT NULL AUTO_INCREMENT PRIMARY_KEY, > name VARCHAR(30) NOT NULL ); > > and then run the following ruby commands: > > rails -d mysql moviecritic (creates all the necessary files without any issue.) > > I then modify the config/database.yml to include the root password to > my database and run then ruby the following ruby command: > > ruby script/generate scaffold Movie (creates usual files without error). > > If i now view the db/migrate.create_movies.rb i see the following: > class CreateMovies < ActiveRecord::Migration > def self.up > create_table :movies do |t| > > t.timestamps > end > end > > def self.down > drop_table :movies > end > end > > It doesn''t make a reference to the name column i created! This isYou''ve got things back to front. the migration generator does not look at an existing table. It''s expecting that it will be creating a new table. The scaffolding stuff used to introspect the database but that died a while back These days what you should do is - create your rails app - create the database ruby script/generate scaffold Movie name:string This will create the migration, views and controller. The migration will create a table with a name column called string and the views will show that field. then run rake db:migrate to run the migration (ie actually create the table). Fred> reflected when i navigate to localhost:3000/movies/new i only see a > Back link and a Create Button, i don''t see a NAME FIELD INPUT. > > Has anyone any ideas why this is happening? > Thanks in advance, > Stephen--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the help! Much appreciated! -- 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 -~----------~----~----~----~------~----~------~--~---
I think that''s crap. The scaffold should create the table if it does not exist but if the table already exists then inspect the table and generate the appropriate stuff. What a pain in the ass. On Dec 13 2008, 7:22 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 13, 11:11 am, "Stephen Morrison" <stephen.dmorri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > Hi guys, > > I''m having problems when creating basic web applications using rails > > 2.2 and mySQL databases. > > If I create the following table in a database named moviecritc_development: > > > CREATE TABLE movies ( > > id INT NOT NULL AUTO_INCREMENT PRIMARY_KEY, > > name VARCHAR(30) NOT NULL ); > > > and then run the following ruby commands: > > > rails -d mysql moviecritic (creates all the necessary files without any issue.) > > > I then modify the config/database.yml to include the root password to > > my database and run then ruby the following ruby command: > > > ruby script/generate scaffold Movie (creates usual files without error). > > > If i now view the db/migrate.create_movies.rb i see the following: > > class CreateMovies < ActiveRecord::Migration > > def self.up > > create_table :movies do |t| > > > t.timestamps > > end > > end > > > def self.down > > drop_table :movies > > end > > end > > > It doesn''t make a reference to the name column i created! This is > > You''ve got things back to front. the migration generator does not look > at an existing table. It''s expecting that it will be creating a new > table. > The scaffolding stuff used to introspect the database but that died a > while back > > These days what you should do is > - create your rails app > - create the database > > ruby script/generate scaffold Movie name:string > This will create the migration, views and controller. The migration > will create a table with a name column called string and the views > will show that field. > then run > rake db:migrate > > to run the migration (ie actually create the table). > > Fred > > > reflected when i navigate to localhost:3000/movies/new i only see a > > Back link and a Create Button, i don''t see a NAME FIELD INPUT. > > > Has anyone any ideas why this is happening? > > Thanks in advance, > > Stephen--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---