hey, i have these parameters /backend/fsdocuments/new?parent_class=Product&parent_id=5 parent_id = params[:parent_id] => "5" parent_class = params[:parent_class] => "Product" So i need to find Product item with id = 5 Product.find(5) But how can i convert this string to a object?? Thx -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Nick Brutyn wrote:> hey, > > i have these parameters > /backend/fsdocuments/new?parent_class=Product&parent_id=5 > > parent_id = params[:parent_id] => "5" > parent_class = params[:parent_class] => "Product" > > So i need to find Product item with id = 5 > > Product.find(5) > > But how can i convert this string to a object?? > > Thx > > -- > Posted via http://www.ruby-forum.com/."Hash".constantize.new #=> {} _Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
_Kevin wrote:> Nick Brutyn wrote: >> Product.find(5) >> >> But how can i convert this string to a object?? >> >> Thx >> >> -- >> Posted via http://www.ruby-forum.com/. > > "Hash".constantize.new #=> {} > > _Kevinthx it works -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---