I’m trying to pass some values through a link and I want them to be invisible. These are the options I’ve tried:
<%= link_to 'Add comment', :controller => :comments, :action => :new, :idea_id => @idea.id, :user_id => @idea.user.id, :method => :post %>
<%= link_to 'Add comment',{ :controller => :comments, :action => :new, :idea_id => @idea.id, :user_id => @idea.user.id}, :method => :post %>
<%= link_to 'Add comment', :controller => :comments, :action => :new, :idea_id => @idea.id, :user_id => @idea.user.id, %>
<%= link_to 'Add comment', new_comment_path, :idea_id => @idea.id, :user_id => @idea.user.id, :method => :post %>
First option – treats method as a parameter:
http://localhost:2000/comments/new?idea_id=1&method=post&user_id=1
Second option – goes like this: http://localhost:2000/comments/new?idea_id=1&user_id=1
and also causes routing error: “Routing Error No route matches “/comments/new”
Third option – loads the form, but of course is like: http://localhost:2000/comments/new?idea_id=1&user_id=1
Fourth option – looks good (http://localhost:2000/comments/new) but the same routing error like the second one.
What am I doing wrong?
Thanks in advance.
PS
I was asked to give my routes, so here they are:
resources :rights
resources :comments
resources :ideas
resources :users
resources :sessions, :only => [:new, :create, :destroy]
root :to => 'main#home'
#match '/comments/new' => "comments#new" # this doesn't help
match '/home', :to => 'main#home'
match '/contact', :to => 'main#contact'
match '/signin', :to => 'sessions#new'
match '/signout', :to => 'sessions#destroy'
match '/signup', :to => 'users#new'
If you have RESTful routes
should be