Created
January 24, 2011 21:32
-
-
Save ezkl/794003 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
# 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