Here's my form



<h1 id="school_name"><%=h @school.name %> (<%=h @school.place %>)</h1>

<h1 id="school_url"><%= link_to @school_url, @school.url %></h1>

<% form_for [...@school, Review.new] do |f| %>



  <p>
  <%= f.label :first_name, "First Name" %><br />
  <%= f.text_field :first_name, :length => 40 %>
  </p>

  <p>
  <%= f.label :body, "Leave a review..." %><br />
  <%= f.text_area :body, :cols => 40, :rows => 6 %>
  </p>




  <p><%= f.submit "Add Review" %></p>

<% end %>

<% unless @school.reviews == [] %>

  <div id="reviews">
    <%= render :partial => @school.reviews %>
  </div>

<% end %>


---


my routes

  map.resources :schools, :has_many => :reviews


and my controller for reivews

class ReviewsController < ApplicationController

  def create

    @school = School.find(params[:school_id])

    @review = @school.reviews.build(params[:review])

    @review.save

    redirect_to @school

  end

end


-----


I'd like to show validation errors in the initial form, so how do I do
the line...

<% form_for [...@school, Review.new] do |f| %>

Is that right?


I realise i need to update the controller to render new if the record
doesnt save...
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to