Rails: multiple-class methods -


i'm presenting users list of assets they've created. can different classes, , each has edit button.

what'd best way write method takes user correct edit form depending on class is?

something 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 better way this? should method go? thanks!

edit

i forgot mention classes either classes or subclasses.

you can link_to 'edit', [:edit, @object], assuming @object listed resource in routes file.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -