Hi-- I''m working my way through the book, Build Your Own Ruby on Rails Web Applications (Sitepoint). I have run into a problem in Chapter 6; I can''t get the ActionController (story.controller.rb) to run correctly. I keep on getting an error which reads: SyntaxError in StoryController#new app/controllers/story_controller.rb:13: parse error, unexpected $, expecting kEND Since I''m new to RoR, I can''t figure out the error message and correct the problem. Can someone help me? Here is the code in the story.controller.rb file: class StoryController < ApplicationController def index @story = Story.find(:first, :order=>''RAND()'') end def new @story = Story.new(params[:story]) if request.post? @story.save redirect_to :action => ''index'' end end Thanks in advance. -- 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 -~----------~----~----~----~------~----~------~--~---
Paul Denlinger wrote:> Hi-- > > I''m working my way through the book, Build Your Own Ruby on Rails Web > Applications (Sitepoint). I have run into a problem in Chapter 6; I > can''t get the ActionController (story.controller.rb) to run correctly. > > I keep on getting an error which reads: > SyntaxError in StoryController#new > app/controllers/story_controller.rb:13: parse error, unexpected $, > expecting kEND > > Since I''m new to RoR, I can''t figure out the error message and correct > the problem. Can someone help me? > > Here is the code in the story.controller.rb file: > > class StoryController < ApplicationController > def index > @story = Story.find(:first, :order=>''RAND()'') > end > def new > @story = Story.new(params[:story]) > if request.post? > @story.save > redirect_to :action => ''index'' > end > end > > Thanks in advance.You have an end missing try this class StoryController < ApplicationController def index @story = Story.find(:first, :order=>''RAND()'') end def new @story = Story.new(params[:story]) if request.post? @story.save redirect_to :action => ''index'' end end end if you indent your code you may spot the error more easily -- 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 -~----------~----~----~----~------~----~------~--~---
Thank you, your suggested change works. I will remember to check my "end" syntax and to indent my code.> > You have an end missing > > try this > > class StoryController < ApplicationController > def index > @story = Story.find(:first, :order=>''RAND()'') > end > > def new > @story = Story.new(params[:story]) > if request.post? > @story.save > redirect_to :action => ''index'' > end > end > end > > if you indent your code you may spot the error more easily-- 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 -~----------~----~----~----~------~----~------~--~---