Guest User

Untitled

a guest
Jan 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. # route.rb has:
  2. # resources :user do
  3. # resources :accounts do
  4. # end
  5.  
  6. class AccountsController < ApplicationController
  7. before_filter :retrieve_user
  8.  
  9. respond_to :html, :json
  10. # GET /accounts
  11. # GET /accounts.json
  12. def index
  13. @accounts = Account.all
  14. @accounts = @user.accounts if @user
  15.  
  16. respond_with @accounts
  17. end
  18.  
  19. protected
  20. def retrieve_user
  21. @user = User.find params[:user_id]
  22. end
  23. end
Add Comment
Please, Sign In to add comment