Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. def home
  2. if current_user
  3. @todos = current_user.todos.where(completed: false)
  4. end
  5. end
  6.  
  7. def complete
  8. if current_user
  9. @todos = current_user.todos.where(completed: !false)
  10. end
  11. end
  12.  
  13. def completed
  14. if @todo.update_attribute(:completed, !@todo.completed)
  15. flash[:success] = "Congratulations, it was successful."
  16. redirect_to dashboard_path
  17. else
  18. flash.now[:error] = "ERROR: Please try again."
  19. render :new
  20. end
  21. end
  22.  
  23. <% @todos.each do |todo| %>
  24. <div class="card hoverable">
  25. <div class ="card-content mh-100">
  26. <span class="card-title"><%= todo.title %></span>
  27. <p><%= todo.item %></p>
  28. </div>
  29. <div class="card-action grey lighten-5">
  30. <p style="margin: 0;">
  31. <%= check_box_tag 'todo[completed]', todo.id, todo.completed, data: { remote: true, url: url_for(controller: :todos, action: :completed, id: todo), method: "POST" }, id: todo.id, :onclick => "Materialize.toast('Todo Completed, Grats!', 4000)" %>
  32. <%= label_tag todo.id, "COMPLETE", :class => 'strikethrough' %>
  33. </p>
  34. </div>
  35. </div>
  36. <% end %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement