我是Ruby on Rails的新手。我正在尝试为我的应用程序创建一个注册页面。在创建新用户时,我收到此错误。非常感谢提前!
路由。 RB
Rails.application.routes.draw do
resources :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
new.html.erb
<div class='container'>
<div class="row">
<div class="login col-lg-6 col-lg-offset-3">
<%= form_for (@userInfo, :url => users_path, :method => 'post') do |f| %>
<label>First Name</label><%= f.text_field(:first_name) %><br/><br/>
<label>Last Name</label><%= f.text_field(:last_name) %><br/><br/>
<label>Email</label><%= f.text_field(:email) %><br/><br/>
<label>Password</label><%= f.text_field(:password) %><br/><br/>
<label>Date of Birth</label><%= f.text_field(:dob) %><br/><br/>
<label>Contact No.</label><%= f.text_field(:contactno) %><br/><br/>
<%= f.submit('Register User') %>
<% end %>
</div>
</div>
</div>
user_controller
class UsersController < ApplicationController
layout 'HomeLayout'
def new
@userInfo = TblUserInformation.new
end
def create
@userInfo = TblUserInformation.new(params[:user])
@userInfo.save
end
end
答案 0 :(得分:0)
正如您的rails routes
告诉您:
POST /users(.:format) users#create new_user
您必须在form_for url属性中使用new_user_path
。