Using: Rails 3.1.1
I have a controller/model/view called Category that is built up on a tree category system using acts_as_tree & parent_id’s. In the Category#Show-view I show a lot of different information: name, description, color, etc.
I call upon Category#Show with category_path(@category) # => e.g. domain.com/category/car
Now I want to create a Store-view that needs:
- Unique paths
- Unique views
but using all other attributes from the Category controller, like the same database tables.
I want to be able to use store_path(@store) # => domain.com/stores/car and access all the data from the Category car-object but show it using the Store#Show-view.
So, basically I want to echo/mirror Category and view the same data in a different manner and call that from a different path. If @category.color # => blue I want @store.color # => blue as well.
I will only use Store with #show and #index (no updated/destroy/edit etc).
It feels like this should be something related to inheriting but I don’t really know where to start or what to do. Could you please bump me in the right direction?
It turns out the easiest way of handling this was by just by just acts as if I was in the CategoryController (while in the Store controller) and use @store = Category.find(params[:id]) and then use @store.