Hi I need something like : <% obj = params[:obj].find(params[:obj_id]) %> <textarea id="mce_edit" style="height:430px; width:100%;"> <%= obj.params[:obj_method] %> </textarea> in a partial. params[:obj] and params[:obj_method] are strings like TrstSysPage, title. params[:obj_id] is number and is only working for the rest I got undefined method `params'' for #<Enumerable::Enumerator:0xb4b38b48> Extracted source (around line #17): 14: <body style="background-color : #AFAFAF; padding: 10px 10px 0 10px;"> 15: <% obj = params[:obj].find(params[:obj_id]) %> 16: <textarea id="mce_edit" style="height:430px; width:100%;"> 17: <%= obj.params[:obj_method] %> 18: </textarea> 19: <p style="padding: 15px 0 0 10px"> I''m stuck :) -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 9, 2009, at 3:06 PM, Ferenc-Lorant Kiss wrote:> Hi > > I need something like : > > <% obj = params[:obj].find(params[:obj_id]) %>Well, you need to look at the documentation for ActiveSupport::Inflector.constantize and Object#send http://www.railsbrain.com/api/rails-2.1.2/doc/index.html?a=M000945&name=constantize ri Object#send params[:obj].constantize.find(params[:obj_id]).send(params[:obj_method]) But you should know that this is potentially disastrous, say if params has {:obj => "ImportantModel", :obj_id => "1", :obj_method => "destroy"}. (Repeat with all other values for :obj_id ;-) Note also that you don''t check for any exceptions (such as ActiveRecord::RecordNotFound or NoMethodError) -Rob> > <textarea id="mce_edit" style="height:430px; width:100%;"> > <%= obj.params[:obj_method] %> > </textarea> > > in a partial. params[:obj] and params[:obj_method] are strings like > TrstSysPage, title. params[:obj_id] is number and is only working for > the rest I got > > undefined method `params'' for #<Enumerable::Enumerator:0xb4b38b48> > > Extracted source (around line #17): > > 14: <body style="background-color : #AFAFAF; padding: 10px 10px 0 > 10px;"> > 15: <% obj = params[:obj].find(params[:obj_id]) %> > 16: <textarea id="mce_edit" style="height:430px; width:100%;"> > 17: <%= obj.params[:obj_method] %> > 18: </textarea> > 19: <p style="padding: 15px 0 0 10px"> > > I''m stuck :) > -- > Posted via http://www.ruby-forum.com/.Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn wrote:> params[:obj].constantize.find(params[:obj_id]).send(params[:obj_method]) > > But you should know that this is potentially disastrous, say if params > has {:obj => "ImportantModel", :obj_id => "1", :obj_method => > "destroy"}. (Repeat with all other values for :obj_id ;-) > > Note also that you don''t check for any exceptions (such as > ActiveRecord::RecordNotFound or NoMethodError)Thanks! I use this just for edit some html data with mceEdit. All params comes from regularly checked edit form, but I needed a new screen/window for those text fields :) Thanks again I''ll try tomorrow . Here is :) already tomorrow -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
You are the best!!! It''s working ! I haven''t patience till morning Long live rails community :) -- 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?hl=en -~----------~----~----~----~------~----~------~--~---