Skip to content

Instantly share code, notes, and snippets.

@jordanthomas
Created October 9, 2012 00:32
Show Gist options
  • Save jordanthomas/3855828 to your computer and use it in GitHub Desktop.
Save jordanthomas/3855828 to your computer and use it in GitHub Desktop.
nested resource errors
class InvitesController < ApplicationController
def create
@project = Project.find(params[:project_id])
@invite = @project.invites.build(params[:invite])
if @project.save
redirect_to project_url(@project), :notice => 'Success message.'
else
render # ?? project/show ??
end
end
end
<!-- Details of @project rendered up here -->
<!-- Render errors for failed @invite here -->
<%= form_for([@project, @invite]) do |f| %>
<p>
<%= f.label :email %><br>
<%= f.text_field :email %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment