This is probably an easy guess for some, but after searching the web
for quite some time, I’ve concluded that I need help understanding
I’m creating an ad application where people can sell and buy items
through their own ads. An ad belongs to one category, and therefore
the question: When a user views all the current ads as a list
(webisteurl/ads) - how do I make the categories show up next to that
list like a clickable sorting menu?
I’m not 100% sure which part you’re stuck on. To get the association set up you need to look in to ActiveRecord Relationships, in particular has_and_belongs_to_many.
class Advert < ActiveRecord::Base
Then in the view do something along the lines of:
…<%= @advert.content %>…
You’d have a category controller; maybe using restful routes or a named route such as:
map.category “/category/:id”, :controller => “categories”, :action => “show”
In that controller you’d do:
And iterate over those articles in the view.
Depending on where you were stuck, hopefully that’s given you some hints to get you moving. If not, post back with more details.