I need a button on the edit page to change attribute value
I am new to Rails. In my project, I have a task controller and a tasks table with a colu开发者_开发知识库mn name task_status
. When task is saved, the status is set to open
. Now, I want to place a mark closed
button on the edit view page to set the status to closed
.
You can do this in several ways. One way would be to include a check box, named close_task
in your form. When this check box is checked and the form is submitted, you check for param[:close_task]
.
So for example:
def update
if param[:close_task]
@task.status = 'closed'
@task.save
end
...
end
精彩评论