On a page of an organization I have a partial that shows the users with the moderator role for that organization. Behind each user/moderator there's a link to remove that role. However, this link isn't working. When clicking it, nothing happens. In the url bar of the browser it only shows new text: https://url/organizations/ek99?data[confirm]=Are+you+certain%3F&data[method]=post&data[organization_id]=100&data[stakeholder_id]=113&data[url]=%2Fremovemoderator%2Fek99
. Does anyone perhaps see what is wrong with this code?
In the organizations controller:
def show
@organization = Organization.friendly.find(params[:id])
@moderators = User.with_role(:moderator, @organization)
end
The view page calls on the partial using <%= render 'users/moderator', collection: @moderators %>
. The partial contains for each moderator the link:
<%= link_to image_tag("delete.gif", title: "remove as moderator", class: 'profile-icon-small'),
data: { user_id: moderator.id, organization_id: @organization.id, method: :post, url: removemoderator_path, confirm: "Are you certain?" } %>
Routes:
post 'removemoderator/:id'=> 'users#remove_moderator', as: 'removemoderator'
Users controller method:
def remove_moderator
@organization = Organization.friendly.find(params[:id])
remove_modrights(@organization)
end
User model method:
def remove_modrights(organization)
self.remove_role :moderator, organization
end
The url in link should contain id.