Skip to content

Commit

Permalink
generate json outside request
Browse files Browse the repository at this point in the history
  • Loading branch information
iannono committed Aug 26, 2013
1 parent 24ba966 commit 9e7f108
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
module ApplicationHelper
def json_for(target, options = {})
options[:scope] ||= self
options[:url_options] ||= url_options
target.active_model_serializer.new(target, options).to_json
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1>Articles</h1>

<div id="articles">
<div id="articles" data-articles="<%= json_for @articles %>">
<% @articles.each do |article| %>
<h2>
<%= link_to article.name, article %>
Expand Down

0 comments on commit 9e7f108

Please sign in to comment.