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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -