I got a bit of a newbie question. I'm trying to pass a variable from my view to my controller. Is there anyway my method in my controller can receive variables from my view?
Post view: show.html.erb:
....
<%=link_to "Add relationship", :method => :add_relationship(@rela) %>
Controller: post.controller.rb:
def add_relationship(rela)
@post = Post.find(params[:id])
if current_user.id == @post.user_id
@post.rel_current_id = rela.id
@post.save
redirect_to relationships_url
else
redirect_to posts_url, :notice => "FY!"
end
end
Thanks in advance :)