deffind_commentable
params.each do |name, value|
if name =~ /(.+)_id$/return$1.classify.constantize.find(value)
endendnilend
i did :
ruby
deffind_commentable
params.each_with_index do |elem, index|
if index == params.length - 1if elem[0].to_s =~ /(.+)_id$/return$1.classify.constantize.find(elem[1])
endendendend
which allow to find the last controller param with its Id , and for me works well to get the @commentable type and id
To adapt the magic sauce with nested resources :
i did :
which allow to find the last controller param with its Id , and for me works well to get the @commentable type and id
Hope it helps someone, cheers