views:

82

answers:

1

Hi, rails newbie here. I've started making a value based to-do list.

So far I've scaffolded my app like this:

dir> rails --database=mysql test1
dir> cd test1
test> ruby script/generate scaffold list item:string done:boolean value:int
[Changed default value of done to false in the migration file]
test> rake db:migrate

All is working well, and I've changed my index view to do what I want except a easier way to flag a task as done. Instead of using the link_to helper to go to an edit page every time I want to change the value of a task's done boolean from false to true I want to be able to press a button that would change the value of this boolean. How would I do this? I've looked around both the net and my Agile Web Development with Rails and found nothing. Can anyone point me in the right direction?

Edit: This is how the edit view changes the values in the table:

<h1>Editing list</h1>

<%= error_messages_for :list %>

<% form_for(@list) do |f| %>
  <p>
    <b>Item</b><br />
    <%= f.text_field :item %>
  </p>

  <p>
    <b>Done</b><br />
    <%= f.check_box :done %>
  </p>

  <p>
    <%= f.submit "Update" %>
  </p>
<% end %>


<%= link_to 'Show', @list %>
<%= link_to 'Back', lists_path %>
+1  A: 

This blog post has roughly what you are looking for. Just change the images so they are the buttons you want.

srboisvert