Hello, I''m following a guide on creating a migration, but the migrate is failing due to the following errors: Line 7: Unexpected ''\n'' expecting tCOLON2 or ''{'' or ''.'' Line 14: $END expecting KEND But I can''t find any mistakes. Any help appreciated. I use sometimes notepad and sometimes crimson editor for my programming development. If there''s a better editor that would not cause these problems (as they don''t seem to be typing erors) I''d appreciate the help. I pasted this straight from Crimson Editor: class CreatePosts < ActiveRecord::Migration def self.up create_table :posts do |t| t.column :title, :string t.column :body, :text t.column :created_at, :string t.lock_version, :integer end end def self.down drop_table :posts end end H. -- 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 -~----------~----~----~----~------~----~------~--~---
This looks strange => t.lock_version, :integer Is the comma needed? I''m learning too and have never used t.lock_version. -Mel On 6/7/07, Hussein Patwa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hello, > > I''m following a guide on creating a migration, but the migrate is > failing due to the following errors: > > Line 7: Unexpected ''\n'' expecting tCOLON2 or ''{'' or ''.'' > Line 14: $END expecting KEND > > But I can''t find any mistakes. > > Any help appreciated. > > I use sometimes notepad and sometimes crimson editor for my programming > development. If there''s a better editor that would not cause these > problems (as they don''t seem to be typing erors) I''d appreciate the > help. > > I pasted this straight from Crimson Editor: > > class CreatePosts < ActiveRecord::Migration > def self.up > create_table :posts do |t| > t.column :title, :string > t.column :body, :text > t.column :created_at, :string > t.lock_version, :integer > end > end > > def self.down > drop_table :posts > end > end > > H. > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Hussein Patwa
2007-Jun-07 22:48 UTC
Re: Rake Migrate failing - but can''t find syntax errors
Ok, good news but at the same time bad news. Good news is that it''s working. I removed the lock_version statement after loading the file into a windows version of emacs, and also just removed anything after the last end statement (even though I couldn''t find anything) and now it migrates fine. Bad news, I don''t know why the lock_version was having that effect, I found the statement through google that was supposed to be, well a locking mechanism to ensure the same database item couldnt be edited at the same time by two users. I can only suppose it didn''t work. Why I don''t know. I hate these types of errors, particularly the $END and KEND as I don''t know what they mean. I don''t have any other editors than notepad, Editpad Pro and Crimson Editor, and iit seems that even these put hidden characters in that mess things up. Any recommendations for a no nonsense editor would be welcome. I do need something that is accessible though as I''m partially sighted, so something easy to use. H. -- 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 -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2007-Jun-08 00:12 UTC
Re: Rake Migrate failing - but can''t find syntax errors
On Jun 7, 2007, at 6:48 PM, Hussein Patwa wrote:> I hate these types of errors, particularly the $END and KEND as I > don''t > know what they mean. I don''t have any other editors than notepad, > Editpad Pro and Crimson Editor, and iit seems that even these put > hidden > characters in that mess things up. Any recommendations for a no > nonsense editor would be welcome. I do need something that is > accessible though as I''m partially sighted, so something easy to use. > > H.These are tokens from the parser: kSOMETHING usually means that a token that looks like something is involved, in this case kEND is the "end" of some block/loop/if construct. The $ (or $END) often means the end of the file. They''re not literally "$END" or "kEND" in the source so your editor will do just fine. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Gernon
2007-Jun-08 14:34 UTC
Re: Rake Migrate failing - but can''t find syntax errors
> t.lock_version, :integerThis is definitely the problem. I believe you meant: t.column lock_version, :integer However, please don''t add this without actually understanding optimistic locking. It won''t automatically take care of everything involved with making sure two people aren''t editing a record at the same time - it just causes an ActiveRecord::StaleObjectError when trying to save the record if it has changed since the user loaded it. Your application still has to handle that error. For more information: http://api.rubyonrails.com/classes/ActiveRecord/Locking/Optimistic.html http://wiki.rubyonrails.org/rails/pages/MagicFieldNames http://www.ruby-forum.com/topic/61754 -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks Chris for clearing that up - at least for me. --Mel On 6/8/07, Chris Gernon <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > t.lock_version, :integer > > This is definitely the problem. I believe you meant: > > t.column lock_version, :integer > > However, please don''t add this without actually understanding optimistic > locking. It won''t automatically take care of everything involved with > making sure two people aren''t editing a record at the same time - it > just causes an ActiveRecord::StaleObjectError when trying to save the > record if it has changed since the user loaded it. Your application > still has to handle that error. > > For more information: > http://api.rubyonrails.com/classes/ActiveRecord/Locking/Optimistic.html > http://wiki.rubyonrails.org/rails/pages/MagicFieldNames > http://www.ruby-forum.com/topic/61754 > > -- > 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 -~----------~----~----~----~------~----~------~--~---