【发布时间】:2019-01-17 13:04:09
【问题描述】:
我需要有关此问题的帮助。我有任务控制器
RESTful 动作和
private
def new_status
@tasks.update!(active: params[:active])
flash[:notice] = "Status update"
redirect_to action: "index"
end
有路线
resources :tasks do
get :new_status, on: :member
end
但我无法通过此链接更改数据库中的活动值
<%=link_to "send data", new_status_task_path(task.id, :active => false) %>
在 *.html.erb 中
<% @tasks.where(active: true).order(:priority).each do |task| %>
<li class="task">
<%= link_to task.title, task, class: "task-title text-dark" %>
<span class="task-btn">
<%=link_to "send data", new_status_task_path(task.id, :active => false) %>
<%= link_to '', '', class: "fas fa-bell text-dark icon" %>
<%= link_to '', edit_task_path(task), class:"fas fa-cogs text-dark mx-2 icon" %>
<%= link_to '', task, method: :delete, data: { confirm: 'Are you sure?' }, class:"far fa-trash-alt text-dark icon" %>
</span>
</li>
<% end %>
【问题讨论】:
标签: ruby-on-rails ruby controller action