Topic: Change scope and results via Ajax
I have a Page (model/controller/view) that pulls together a lot of different data. One part of that data is the current_user's accounts, which have_many items. When home/index is first shown, I'm defaulting to the first Account the user has, and the associated Items:
@account = current_user.acounts.find(:first)
@items = @acount.items
What I want to do is have a dropdown (select_tag) that lists all of the user's accounts. When the user picks from that list, the items shown refreshes to those of that account.
How do I pass back from the select_tag to the controller, then set the @account to the right id? Ideally, I want to replace the items with the items from the selected account, but I'm trying to get my head around how to set the id of the current account...