Rails: multiple-class methods
I'm presenting users a list of assets they've created. They can be
different classes, and each has an edit button.
What'd be the best way to write a method that takes the user to the
correct edit form depending on what the class is?
Something like this is what I'm thinking:
def edit_asset(class, id)
if class == 'Photo'
redirect_to edit_photo_url(id)
elsif class == 'Audio'
redirect_to edit_audio_url(id)
elsif ...
...
end
end
Is there a better way to do this? Any where should this method go? Thanks!
No comments:
Post a Comment