What is your solution to the problem if you have a model that is not nested and nested, for example, products:
a “Product” may belong to “say” “Event,” and the Product may also be independent.
This means that I can have these routes:
map.resources :products # /products map.resources :events do |event| event.resources :products # /events/1/products end
How do you deal with this in your views correctly?
Note: this is for admin panel. I want to have a Create Event page with a sidebar for creating tickets (Product), forms and checking who rsvp'd is. Thus, you click on the button on the sidebar "Event Tickets", and it will transfer you to /events/my-new-event/tickets . But there is also a root tab “Products” for the admin panel, which can display tickets and other random products. The “tickets” and “products” views look 90% the same, but the tickets will have some information about the event to which it belongs.
It looks like I would need to have these types:
- Products /index.haml
- Products /show.haml
- Events / Products / index.haml
- Events / Products / show.haml
But it does not seem dry. Or I could have conditional expression checks to see if the product had an event ( @product.event.nil? ), But then the views would be hard to understand.
How do you deal with these situations?
Many thanks.
source share