KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm new to rails and I'm kind of stuck with this design problem, that might be easy to solve, but I don't get anywhere: I have two different kinds of advertisements: highlights and bargains. Both of them have the same attributes: title, description and one image (with paperclip). They also have the same kind of actions to apply on them: index, new, edit, create, update and destroy. I set a STI like this: Ad Model: ad.rb class Ad < ActiveRecord::Base end Bargain Model: bargain.rb class Bargain < Ad end Highlight Model: highlight.rb class Highlight < Ad end The problem is that I'd like to have only one controller ( AdsController ) that executes the actions I said on bargains or highlights depending on the URL, say www.foo.com/bargains[/...] or www.foo.com/highlights[/...]. For example: GET www.foo.com/highlights => a list of all the ads that are highlights. GET www.foo.com/highlights/new => form to create a new highlight etc... How can i do that? Thanks!
Tags (comma-separated)
Save Edits
Cancel