开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜