Muhammad Ahsan Muhammad Ahsan - 4 months ago 23
Ruby Question

getting Missing Template error while creating a new user


Missing template admin/citizens/create, admin/application/create, application/create with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder, :rabl]}. Searched in: * "/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"


.....here is the code

= 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'

Answer

I think you need to add else part to handle when user is not saved

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
Comments