Skip to content

Instantly share code, notes, and snippets.

@bmarcot
Created November 4, 2014 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmarcot/55e3422f241a632f8997 to your computer and use it in GitHub Desktop.
Save bmarcot/55e3422f241a632f8997 to your computer and use it in GitHub Desktop.
To include any methods on the model, use :methods.
class Content
def type
self.class.name
end
end
class TwitterContent
def type
"twitter"
end
end
def show
@contents = ...
respond_to do |format|
format.html
format.json { render :json => @contents.to_json(:methods => :type) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment