Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement