Created
November 13, 2012 23:52
-
-
Save mathias/4069230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I don't do: | |
<%= javascript_tag do %> | |
window.posts = <%= @posts.to_json %> | |
<% end %> | |
I do: | |
<div id="posts" data-url="<%= @posts %>"> | |
And the view is smart enough to know to call to_json on it, works for collections | |
Also: | |
def as_json | |
{} # returns a hash of filtered attributes of model | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment