Skip to content

Commit

Permalink
add meteorite to tasks#create
Browse files Browse the repository at this point in the history
  • Loading branch information
llawlor committed Jul 1, 2015
1 parent c7b8233 commit 9440626
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def index
def create
# create the task
task = Task.create(task_params)
# render the partial to a string
task_string = render_to_string(partial: 'task', locals: { task: task })
# push to redis
$redis.publish(Meteorite.bind_key(Task.all), task_string)
# blank response
head :ok
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/tasks/_task.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<tr>
<tr id="<%= Meteorite.bind_key(task) %>">
<td>
<%= form_for task, remote: true, html: { style: 'float: left; margin-right: 5px;' } do |f| %>
<label>
<%= f.check_box :checked, class: 'task_check' %>
<%= f.check_box :checked, class: 'task_check meteorite', data: { bind_key: Meteorite.bind_key(task), bind_attr: 'checked' } %>
<span class="checkbox_text <%= 'checked' if task.checked?%>"><%= task.text %></span>
</label>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tasks/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<br><br>

<table class="table table-striped table-bordered">
<table class="table table-striped table-bordered meteorite" data-bind-key="<%= Meteorite.bind_key(@tasks) %>">
<% @tasks.each do |task| %>
<%= render partial: 'task', locals: { task: task } %>
<% end %>
Expand Down

0 comments on commit 9440626

Please sign in to comment.