Skip to content

Instantly share code, notes, and snippets.

@danmcclain
Created August 24, 2011 01:08
Show Gist options
  • Save danmcclain/1167069 to your computer and use it in GitHub Desktop.
Save danmcclain/1167069 to your computer and use it in GitHub Desktop.
# route.rb has:
# resources :user do
# resources :accounts do
# end
class AccountsController < ApplicationController
before_filter :retrieve_user
respond_to :html, :json
# GET /accounts
# GET /accounts.json
def index
@accounts = Account.all
@accounts = @user.accounts if @user
respond_with @accounts
end
protected
def retrieve_user
@user = User.find params[:user_id]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment