I’m trying to use link_to to pass a variable from a view to a controller. Here’s what my code in the view looks like:
<%= link_to 'Send Chant', :controller => 'send_chants', :action => 'index', :content => @chant.content %></b>
Here’s what the index action in my ‘send_chants’ controller looks like:
class SendChantsController < ApplicationController
def index(content)
puts content
end
end
Upon clicking the ‘Send Chant’ link, I get a ArgumentError ‘wrong number of arguments (0 for 1)’
I’m sure I’m missing something simple. Any thoughts?
Thanks so much!
Controller actions do not take parameters. All params are passed in via the params hash.. Try something like…