Forum: Ruby on Rails routes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
bingo b. (Guest)
on 2009-02-12 11:52
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?
Hitesh R. (Guest)
on 2009-02-12 12:22
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/
bingo b. (Guest)
on 2009-02-12 19:06
Anyone provide any insight?
This topic is locked and can not be replied to.