Okey, so im kinda new to ruby on rails. Im trying to call a function when im pressing a button. But i have no idea how to do this.
This is basicaly what im trying to do:
<% button_to 'Ban User', call_this_function %>
<% this_function %>
@user = User.find(:id)
@user.deactivated("true")
<% end %>
Here is some actual code that I wrote
<% if has_role?(:admin) %>
<% if [email protected] %>
<% if [email protected]_role?(:admin) %>
<%= link_to 'Ban User', new_discussion_path, class:"button is-danger" %>
<% end %>
<% else %>
<%= link_to 'Unban User', new_discussion_path, class:"button is-success" %>
<% end %>
<% end %>
But this only redirects to a page to where I can create a new discussion. What I'm trying to do is to just call a named function when impressing the button, but do not redirect to some other page. I'm sorry for the lack of code, but please ask if you need some clarification.
Userwith that@user.deactivated("true")