[Rails] Shared code for controllers
Rodrigo Alvarez Fernández
papipo at gmail.com
Fri Dec 16 11:27:47 GMT 2005
Hi,
I think that this is made from a plugin or something in /lib/, but i really
don't know which is the better way:
I have this in my MediasController:
def mediatype_medias_options
if params[:id]
begin
@mediatype = MediaType.find(params[:id])
render :inline => "<%= options_from_collection_for_select @
mediatype.medias, 'id', 'name' %>"
rescue Exception
render :nothing => true
end
else
render :nothing => true
end
end
I use it from a form, that sends a mediatype id, and this renders <options>
for a select (it's something like a hier. select).
Since i must use this kind of thing into some controllers, i wish to follow
the DRY principle, but don't know how.
Could you please give me some advice?
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20051216/915ba7ca/attachment.html
More information about the Rails
mailing list