ruby on rails - How do I send a two chained methods as a symbol? -


in order search posts using friendly_id, use query :

post.friendly.find(params[:id]) 

but need wrap method , send presenter class gem, decent_exposure. gives me fancy place include method fetch object.

by default, method :find . written in code :

def finder   options[:finder] || :find end  scope.send(finder, id) # scope here mean post 

how can send via options, 2 method query symbol?

looking @ documentation if define class method on post should able use that.

class post   def self.find_with_friendly(id)     friendly.find(id)   end end 

then can do

expose(:post, finder: :find_with_friendly) 

pretty sure should work.


Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -