Reputation:
I need help for this issue. I have Task Controller with
RESTful action and
private
def new_status
@tasks.update!(active: params[:active])
flash[:notice] = "Status update"
redirect_to action: "index"
end
Have a routes
resources :tasks do
get :new_status, on: :member
end
But I can't change value active in database with this link
<%=link_to "send data", new_status_task_path(task.id, :active => false) %>
In *.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 %>
Upvotes: 0
Views: 55
Reputation: 23327
Controller actions must be public. Move the definition of new_status
before the private
declaration.
def new_status
@tasks.update!(active: params[:active])
flash[:notice] = "Status update"
redirect_to action: "index"
end
private
# rest of the controller
Upvotes: 2