ruby on rails - Rendering Partial with specific :category_id -
i created categories scaffold
. user's can upload image , add category it. categories created in scaffold shown in dropdown users select.
on image show page
link category ->
<%= link_to @pin.category.name, @pin.category%>
it takes me (for example)
localhost:3000/categories/1
on category show page
want display images share same category.
how do ?
in models define catagory
has_many :images
and image
belongs_to :category
- image should have category_id member of course
then , when have category object in hand (let's @cat), iterate @cat.images
you can read more models , relation in here
Comments
Post a Comment