[Rails] Calling a method from a view using link_to_function
- by Jeff
Hello!
I'm trying to have an image that when clicked associates the selected guideline to a project. I'm using link_to_function which somewhat behaves but I can not get the method I am calling in the link_to_function to redirect to another page. Is there a better way to do this? Below is a bit of my code. I can paste in additional parts if necessary:
<% @guidelines.each do |guideline| %>
<tr>
<td align='center'><%= link_to_function image_tag("../../../images/icons/action_add.png"), add_guideline(guideline) %></td>
<td><%=h guideline.title %></td>
My GuidelinesController.helper method looks like this:
def add_guideline(guideline)
@project = Project.find(params[:project_id])
@project.guidelines << guideline
@project.save
redirect_to dashboard_path #doesn't work :(
end