I have a Rails app and in it I have two models, widget and votes. Votes are used to keep track of the desirability of a widget.
In my models I have:
class Vote < ActiveRecord::Base
belongs_to :widget
end
class Widget < ActiveRecord::Base
has_many :votes
end
I am trying to figure out the best way to route votes up and votes down. At the moment I am leaning towards this:
resources :widgets do
member do
put :vote_up
put :vote_down
end
end
Where the respective functions reside in the widgets' controller and it creates and saves votes in that controller. However, I realize that this doesn't really fit correctly with the MVC idea (votes should be created and built in their own controller). Is this acceptable or should I be doing something more like:
resources :widgets do
resources :votes do
member do
put :vote_up
put :vote_down
end
end
end