问题
I am trying to set some params
in a form_for
in my view to be used by that View's Controller method called pay
. Unfortunately I am getting the following error:
NameError in WebApplications#pay
undefined local variable or method `pay' for #<#<Class:0x000001082e1e00>:0x000001082e0fc8>
Here is my View:
<%= form_for pay do |f| %>
<%= f.label :first_name %>:
<%= f.text_field :first_name, params[:first_name] %><br />
<%= f.label :last_name %>:
<%= f.text_field :last_name, params[:last_name] %><br />
<%= f.label :card_number %>:
<%= f.text_field :card_number, params[:card_number] %><br />
<%= f.label :expiration_date %>:
<%= f.text_field :expiration_date, params[:expiration_date] %><br />
<%= f.label :cvv2_cvc2 %>:
<%= f.text_field :cvv2_cvc2, params[:cvv2_cvc2] %><br />
<%= f.submit %>
<% end %>
Here is my Controller:
class WebApplicationsController < ApplicationController
def thing
NotificationsMailer.send_application(params[:another_field]).deliver
end
def create
render nothing: true
end
def pay
#TODO: implement
end
end
来源:https://stackoverflow.com/questions/24704389/rails-4-form-form-controllermethodname-not-working