# Routes

**URL:** <https://www.ruby-forum.com/t/routes/160155>\
**Category:** Rails\
**Created:** [February 12, 2009, 10:52am UTC](https://www.ruby-forum.com/t/routes/160155 "2009-02-12T10:52:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [February 12, 2009, 10:52am UTC](https://www.ruby-forum.com/t/routes/160155/1 "2009-02-12T10:52:52Z")

</div>

I’m trying to figure this.

in my schools controller i want to do this…

# implement a create action to create just the review for the

School…  
def create\_review\_for\_a\_school

```
@review = Review.new
@school = School.find(params[:school_id])
@review = @school.reviews.build(params[:review])

if @review.save # The creation worked....do this

   flash[:notice] = 'Review was successfully updated.'
   format.html { redirect_to(@school) }
   # format.xml { head :ok }

else # if it didnt save do this...
   format.html { render :action => "show" }
end

```

end

as a result I think i need a route…something like this…

map.connect ‘/schools/:school\_id/reviews/new’, :controller =\> ‘schools’,  
:action =\> ‘create\_review\_for\_a\_school’

and also my form submit button for creating a review - how should that  
look ?

I guess like this…

\<% form\_for [@school, Review.new] do |f| %\>

* * *

But it’s still going to the reviews new action I’d like it to go to the  
def create\_review\_for\_a\_school action?

any tips?

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [February 12, 2009, 11:22am UTC](https://www.ruby-forum.com/t/routes/160155/2 "2009-02-12T11:22:40Z")

</div>

bingo bob wrote:

> I’m trying to figure this.
> 
> in my schools controller i want to do this…
> 
> result I think i need a route…something like this…
> 
> map.connect ‘/schools/:school\_id/reviews/new’, :controller =\> ‘schools’,  
> :action =\> ‘create\_review\_for\_a\_school’
> 
> * * *
> 
> But it’s still going to the reviews new action I’d like it to go to the  
> def create\_review\_for\_a\_school action?
> 
> any tips?

Here you can find the way of routing, I think It help’s you.

[http://rdr.rubyforge.org/](http://rdr.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [February 12, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/routes/160155/3 "2009-02-12T18:06:39Z")

</div>

Anyone provide any insight?
