Skip to content

Instantly share code, notes, and snippets.

@ezkl
Created January 24, 2011 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezkl/794003 to your computer and use it in GitHub Desktop.
Save ezkl/794003 to your computer and use it in GitHub Desktop.
# routes.rb
resources :clients do
resources :payments
end
# views/clients/index.html.haml
= link_to 'New Payment', new_client_payment_path(client)
# controllers/payments_controller.rb
def new
@payment = Payment.new
respond_to do |format|
format.html # new.html.erb
end
end
def create
@payment = Payment.new(params[:payment])
respond_to do |format|
if @payment.save
format.html { redirect_to(root_path, :notice => 'Payment was successfully created.') }
else
format.html { render :action => "new" }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment