Created
August 30, 2012 22:06
-
-
Save binnyg/3542535 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Models | |
---------------------------------------- | |
Invitation | |
has_many :comments | |
Comment | |
belongs_to :invitation | |
Controller | |
---------------------------------------- | |
class InvitationsController < ApplicationController | |
def show | |
@invitation = Invitation.find(params[:id]) | |
respond_with(@invitation) | |
end | |
end | |
routes.rb | |
---------------------------------------- | |
resources :invitations do | |
member do | |
post 'create_comment' | |
end | |
end | |
View show.html.erb [http://localhost:3000/invitations/1] | |
---------------------------------------- | |
<p> | |
<b>Title:</b> | |
<%= @invitation.title %> | |
</p> | |
<%= simple_form_for @comment, :url => create_comment_invitation_path(@invitation) do |f| %> | |
<%= f.input :comment, :label => 'Comment', :placeholder => 'Enter Comment' %> | |
<%= link_to 'Submit', create_comment_invitation_path(@invitation) , :class => 'btn' %> | |
<% end %> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment