我很难实现这一点。此外,我在控制器的索引页面上遇到了“参数数量错误(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 %>