Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ApplicationSerializer < ActiveModel::Serializer
- def self.belongs_to_object(attribute, path_name)
- belongs_to attribute do
- include_data false
- if object.send(attribute)
- path = "#{path_name}_url"
- link(:related) { self.send(path) }
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement