我正在尝试创建自定义管理表单以创建新用户。
以下是表格:
管理员/ newwebsite.html.erb
<%= form_for(@branch) do |f| %>
<div><%= f.label :branch %><br />
<%= f.text_field :branch, autofocus: true %></div>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %></div>
<div><%= f.submit "Sign up" %></div>
<% end %>
controller:controllers / admins_controller.rb
def newwebsite
@branch = Branch.new
end
def newwebsiteparams
params.require(:branch).permit(:branch, :email, :password, :password_confirmation)
end
def create
@branch = Branch.create(newwebsiteparams)
end
路线:
get 'admins/dashboard'
get 'admins/newwebsite'
post 'admins/create' => 'admins#create'
错误:
undefined method `branches_path' for #<#<Class:0x57414d8>:0x57409f8>
任何帮助肯定会受到赞赏。