Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def home
- if current_user
- @todos = current_user.todos.where(completed: false)
- end
- end
- def complete
- if current_user
- @todos = current_user.todos.where(completed: !false)
- end
- end
- def completed
- if @todo.update_attribute(:completed, !@todo.completed)
- flash[:success] = "Congratulations, it was successful."
- redirect_to dashboard_path
- else
- flash.now[:error] = "ERROR: Please try again."
- render :new
- end
- end
- <% @todos.each do |todo| %>
- <div class="card hoverable">
- <div class ="card-content mh-100">
- <span class="card-title"><%= todo.title %></span>
- <p><%= todo.item %></p>
- </div>
- <div class="card-action grey lighten-5">
- <p style="margin: 0;">
- <%= 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)" %>
- <%= label_tag todo.id, "COMPLETE", :class => 'strikethrough' %>
- </p>
- </div>
- </div>
- <% end %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement