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
Post a Comment