I'd like to pass parameter not related to model by form_for on rails.I want to pass 'address' data, that is not related to product model, from view to controller. The following is my code, however it returned the next error. Could you tell me how to solve this problem?
Completed 500 Internal Server Error in 11ms (ActiveRecord: 0.1ms) ActionView::Template::Error (wrong number of arguments (1 for 2..5)):
products_controller
class ProductsController < ApplicationController
~~~~
def transfer
@product = Product.new
end
def transfer_done
my_address = params[:my_address]
wallet = Wallet.find_by(address:my_address)
redirect_to root_url
end
~~~~
end
transfer.html.erb
<% provide("transfer") %>
<p>
<%= form_for @product, :url => {:action => 'transfer_done'} do |f| %>
<div>
<%= check_box :my_address %> <---Error occurred here.
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
</p>
You may try <%= text_field_tag :my_address %> inside your form
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With