# Action Controller: Getting syntax error

**URL:** <https://www.ruby-forum.com/t/action-controller-getting-syntax-error/88436>\
**Category:** Rails\
**Created:** [March 11, 2007, 12:54am UTC](https://www.ruby-forum.com/t/action-controller-getting-syntax-error/88436 "2007-03-11T00:54:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [March 11, 2007, 12:54am UTC](https://www.ruby-forum.com/t/action-controller-getting-syntax-error/88436/1 "2007-03-11T00:54:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [March 11, 2007, 1:36am UTC](https://www.ruby-forum.com/t/action-controller-getting-syntax-error/88436/2 "2007-03-11T01:36:00Z")

</div>

Paul D. 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

---

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [March 11, 2007, 2:40am UTC](https://www.ruby-forum.com/t/action-controller-getting-syntax-error/88436/3 "2007-03-11T02:40:35Z")

</div>

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
