Hi all Im trying to make a simple message board using this tutorial http://www.netmag.co.uk/zine/tools/ror-back-on-track However I have hit a problem when I do rake db:migrate it has a problem with the post_table migrate file, any help with this would be great. ./db/migrate//002_create_posts_table.rb:10: syntax error, unexpected tCONSTANT, expecting kEND FOREIGN KEY(discussion_id) REFERENCESdiscussions(id) class CreatePostsTable < ActiveRecord::Migration def self.up create_table :posts do |table| table.column :body, :text table.column :created_at, :datetime, :null => false table.column :name, :string, :limit=>100 table.column :discussion_id, :integer, :null => false end execute ALTER TABLE posts ADD CONSTRAINT fk_posts FOREIGN KEY(discussion_id) REFERENCES discussions(id) end def self.down drop_table :posts end end -- 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 -~----------~----~----~----~------~----~------~--~---
Mark Bush
2008-Mar-08 19:52 UTC
Re: simple message board: syntax error, unexpected tCONSTANT
Alan Red wrote:> execute ALTER TABLE posts ADD CONSTRAINT fk_posts > FOREIGN KEY(discussion_id) REFERENCES discussions(id)A migration is just Ruby code and this is not Ruby. I suspect you want: execute "ALTER TABLE posts ADD CONSTRAINT fk_posts FOREIGN KEY(discussion_id) REFERENCES discussions(id)" I suspect the quotes got stripped out when the snippet was displayed in the article. Along with the indentation. -- 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 -~----------~----~----~----~------~----~------~--~---
Alan Red
2008-Mar-09 08:00 UTC
Re: simple message board: syntax error, unexpected tCONSTANT
Mark Bush wrote:> Alan Red wrote: >> execute ALTER TABLE posts ADD CONSTRAINT fk_posts >> FOREIGN KEY(discussion_id) REFERENCES discussions(id) > > A migration is just Ruby code and this is not Ruby. > > I suspect you want: > > execute "ALTER TABLE posts ADD CONSTRAINT fk_posts > FOREIGN KEY(discussion_id) REFERENCES discussions(id)" > > I suspect the quotes got stripped out when the snippet was displayed in > the article. Along with the indentation.Thanks for this, still a newbie at ruby on rails but starting to enjoy using it. Much more easier than php. Now the quotes are there I can understand why this wouldn''t really be ruby code. -- 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 -~----------~----~----~----~------~----~------~--~---