0

我很难实现这一点。此外,我在控制器的索引页面上遇到了“参数数量错误(1 代表 0)”错误。

路线.rb

resources :potentialcandidates, :only => [:index, :send, :process]
get 'potentialcandidates/send' => 'potentialcandidates#send', :as => :send_potentialcandidate
post 'potentialcandidates/process' => 'potentialcandidates#process', :as => :process_potentialcandidate

潜在候选人_控制器.rb

  class PotentialcandidatesController < ApplicationController
   def index
    end

   def process
    @name = params[:name]
    @email = params[:email]
    # Add user to user model
    @user = User.create(email: @email, name: @name, status: "active")
   end
 end

index.html.erb
<a href="<%= send_potentialcandidate_path %>">Add</a>

发送.html.erb

    <%= form_tag process_potentialcandidate_path do %>
      <%= text_field_tag "name" %>
      <%= text_field_tag "email" %>
      <%= submit_tag %>
    <% end %>
4

1 回答 1

2

process是一个方法,ActionController::Base你不想在你的控制器中覆盖它。

更改名称,更新您的路线和表格,并重新启动服务器;它应该工作得很好。

于 2013-08-01T18:52:47.770 回答