我在執行此操作時遇到困難。此外,我遇到了我的控制器的索引頁上的「錯誤的參數數量(1爲0)」錯誤。Ruby on Rails:處理未鏈接到模型的表單
的routes.rb
resources :potentialcandidates, :only => [:index, :send, :process]
get 'potentialcandidates/send' => 'potentialcandidates#send', :as => :send_potentialcandidate
post 'potentialcandidates/process' => 'potentialcandidates#process', :as => :process_potentialcandidate
potentialcandidates_controller.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>
send.html.erb
<%= form_tag process_potentialcandidate_path do %>
<%= text_field_tag "name" %>
<%= text_field_tag "email" %>
<%= submit_tag %>
<% end %>
什麼是索引頁的其餘部分?您的錯誤來自將參數發送給不需要的方法。 –
這就是我的索引頁上的一個鏈接。 – Julia
你確定錯誤來自索引嗎? –