I have a model, Report, which is polymorphic. So many yen on my site can have many of them.
And I would like to have a common controller for publishing it. Its very simple model has only text message and association.
in my routes im doing something like
map.resources :users, :has_many => [ :reports ]
map.resources :posts, :has_many => [ :reports ]
but in my report_controller, I would like to get a relationship out with it coming.
as:
before_filter :get_reportable
def get_reportable
reportable = *reportable_class*.find params[:reportable_id]
end
Is it possible?
how can i get reportable_class and reportable_id?
I can get params [: user_id] when it comes from the user controller, or params [: post_id] when it comes from messages. I could do business with all relationships, but it doesn't seem like a clean solution at all ...
having a polymorphic bond would be the best, is there any way?