缺少模板admin / citizen / create,admin / application / create,application / create with {:locale => [:en],:formats => [:html],:variants => [], :handlers => [:erb,:builder,:raw,:ruby,:coffee,:haml,:jbuilder,:rabl]}。搜索:*" / Users / aa / Sites / Active Shehri / activeshehri-mongo / app / views" *" /Users/aa/.rvm/gems/ruby-2.2.2@activeshehri/gems/wiselinks-1.2.1/app/views" *" /Users/aa/.rvm/gems/ruby-2.2.2@activeshehri/gems/rails_admin-0.6.6/app/views" *" /Users/aa/.rvm/gems/ruby-2.2.2@activeshehri/gems/kaminari-0.16.1/app/views" *" /Users/aa/.rvm/gems/ruby-2.2.2@activeshehri/gems/devise_invitable-1.5.5/app/views" *" /Users/aa/.rvm/gems/ruby-2.2.2@activeshehri/gems/twitter-bootstrap-rails-3.2.2/app/views" *" /Users/aa/.rvm/gems/ruby-2.2.2@activeshehri/gems/devise-3.4.1/app/views"
.....这是代码
= form_for [:admin, @user] do |f|
.row
.col-lg-6
.panel
.panel-heading Edit Landmark
.panel-body
.form-group
= f.label :first_name
= f.text_field :first_name, class: 'form-control'
.form-group
= f.label :last_name
= f.text_field :last_name, class: 'form-control'
.form-group
= f.label :email
= f.text_field :email, class: 'form-control'
.form-group
= f.label :gender
= f.text_field :gender, :class => 'form-control'
.form-group
= f.label :contact_no
= f.text_field :contact_no, :class => 'form-control'
.form-group
= f.label :address
= f.text_field :address, class: 'form-control'
= f.submit 'Save', class: 'btn btn-primary btn-submit btn-lg pull-right'
= link_to "Back", admin_home_user_panel_path, class: 'btn btn-primary btn-submit btn-lg pull-left'
答案 0 :(得分:0)
错误是因为您的create.html.erb
文件夹中没有名为views/admin/citizens
的文件。
在Rails中,如果您没有告诉它在Controller方法的末尾重定向或呈现特定模板,它会推断出要渲染的模板,因此:
class UsersController < ApplicationController
def create
@user = User.create(name: params[:name])
end
end
如果在此处运行create方法,则将创建一个用户,然后Rails将尝试呈现模板views/users/create.html.erb
。通常情况下,您将没有具有该名称的模板 - 您可能会执行以下操作:
class UsersController < ApplicationController
def create
@user = User.create(name: params[:name])
redirect_to user_path(@user)
end
end
或者:
class UsersController < ApplicationController
def create
@user = User.create(name: params[:name])
render :awesome_template
end
一切都在这里: http://guides.rubyonrails.org/v2.3.11/action_controller_overview.html#methods-and-actions
答案 1 :(得分:0)
我认为您需要在未保存用户时添加其他部分来处理
def create
@user = User.new(new_params)
if @user.save
redirect_to admin_home_user_panel_path
else
#do render or redirect_to
end
end