SHARE
TWEET

Untitled

a guest Mar 20th, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ApplicationSerializer < ActiveModel::Serializer
  2.   def self.belongs_to_object(attribute, path_name)
  3.     belongs_to attribute do
  4.       include_data false
  5.       if object.send(attribute)
  6.         path = "#{path_name}_url"
  7.         link(:related) { self.send(path) }
  8.       end
  9.     end
  10.   end
  11.  end
RAW Paste Data
Top