I want to click on dropdown item called "User" and "Admin" and this should update role column in my account table to this value.
%tr
%td
.dropdown
%button#dropdownMenuLink.btn.btn-outline.btn-sm.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
=account.role
.dropdown-menu{"aria-labelledby" => "dropdownMenuButton"}
.dropdown-item #{link_to "User", account.update_attribute("role", "user")}
.dropdown-item #{link_to "Admin", account.update_attribute("role", "admin")}
And I get this error:
undefined method `to_model' for true:TrueClass Did you mean? to_yaml
You need to do update of attributes in controller, not in views. You can use link_to to go to an action and pass additional params.
Anyway your controller to handle update and redirect should look like:
accounts_controller.rb
instead of
link_to, you'd better useform_for.