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@AgileConsultingLLC.com