I am new to rails and I am having a hard time coming up with a clean
solution to handle passing vars to controllers and views so that they
will have the data they need to function correctly.
For instance. I have products_controller. This controller manages a
Product model, and Product belongs_to Category.
Within products_controller all CRUD actions are scoped thru the
Categories has_many association IE:
category = Category.find_by_name params[:category]
@product = category.products.find(params[:id])
In order for the products_controller actions to operate they all need
access to params[:category]. Currently I am passing that attribute
around thru a combination of hidden for_for fields and stuff like
link_to 'Edit', edit_product_path(product, :category =>params
I am running into a lot of issues keeping track of passing this info
around through the various views and actions that are in play. It
feels sloppy and prone to problems. It's like I'm working in PHP
Should I use global varibles or sessions to solve these kinds of
Whats the best thing to do here?
Thanks a lot.