0

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!

dougiebuckets
  • 2,383
  • 3
  • 27
  • 37

1 Answers1

5

Controller actions do not take parameters. All params are passed in via the params hash.. Try something like...

class SendChantsController < ApplicationController
  def index
    puts params[:content]
  end
end
Doon
  • 19,719
  • 3
  • 40
  • 44
  • super helpful - thank you! SO is requiring me to wait 6 more mins before i can accept the answer. i'll be sure to do so. – dougiebuckets Dec 14 '12 at 21:56