Followed along with Railscast 052 Update through checkboxes
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
bin
config
db
lib
log
public
test
vendor/assets
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru

README.md

052 Update through Checkboxes

Followed along with Railscast 052 Update through Checkboxes

Blog Post @ PatrickPerey.com

def index
  @incomplete_tasks = Task.where(complete: false)
  @complete_tasks = Task.where(complete: true)
end
def complete
  Task.where(id: params[:task_ids]).update_all(["complete=?", true])
  redirect_to tasks_path, notice: 'Task completed'
end
<%= form_tag complete_tasks_path, method: :put do  %>
  <ul>
    <% @incomplete_tasks.each do |task| %>
    <li>
      <%= check_box_tag "task_ids[]", task.id %>
      <%= task.name %>
    </li>
    <% end %>
  </ul>
  <%= submit_tag "Complete task" %>
<% end %>