Sending parameters to controller via button_to

I have

<%= label_tag :“Enter member code” %>

<%= text_field_tag :membercode%>

<%= button_to “Death/Retired Recovery Letter Printing”, recovery_letter_rpts_path(membercode: membercode) %>

In my controller

def create

membercode = params[:membercode]

exist = Member.find_by_member_code(membercode)

respond_to do |format|

if exist.nil?

format.html{ redirect_to new_recovery_url, notice: ‘Member not found.’} # here you just echo the result

puts “******************************************”

puts “This is the member code #{membercode}” # done

puts “******************************************”

redirect_to(recoveries_path)

else

puts “This is the NO member code #{membercode}”

redirect_to(recoveries_path)

end

end

end

all I want to do is send membercode which is accepted via text_field_tag to the create action of the controller. And there is no form to contain these fields. I want it that way because, there will be more “button_to” which want to send membercode to different controller’s action.

Please help me.

can’t you do that using template?

Can you please elaborate?

Use a form in the view. The form will 'post' the data to the create method in your controller. This is assuming you have the correct routes.

Put the field in a form, then you can have multiple submit buttons
within the form.

Colin