Rails 4: Form_form controllerMethodName not working

谁说胖子不能爱 提交于 2019-12-25 06:47:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!