在Ruby中获取缺少的模板错误

问题描述:

我是Ruby的新手,在单击应用程序中的一个链接时会出现以下错误,该链接应呈现用于创建用户配置文件的表单。我非常感谢任何帮助。在Ruby中获取缺少的模板错误

缺少具有{:locale => [:en],:formats => [:html],:variants => [:,handlers => [:erb, :builder,:raw,:ruby,:jbuilder,:coffee]}。搜索:*“/ home/ubuntu/workspace/app/views”*“/usr/local/rvm/gems/ruby-2.3.0/gems/devise-3.4.1/app/views”

模型/ profile.rb

class Profile < ActiveRecord::Base 
    belongs_to :user 
end 

控制器/ profiles_controller.rb

class ProfilesController < ApplicationController 
    def new 
    # form where a user can fill out their own profile. 
    @user = User.find(params[:user_id]) 
    @profile = @user.build_profile 
    end 
end 

应用/视图/简档/ new.html.erb

<div class="row"> 
    <div class="col-md-6 col-md-offset-3"> 
    <h1 class="text-center">Create Your Profile</h1> 
    <p class="text-center">Be a part of the Dev Match community and fill out  your profile!</p> 
<div class="well"> 
    <%= form_for @profile, url: user_profile_path do |f| %> 
    <div class="form-group"> 
     <%= f.label :first_name %> 
     <%= f.text_field :first_name, class: 'form-control' %> 
    </div> 
    <div class="form-group"> 
     <%= f.label :last_name %> 
     <%= f.text_field :last_name, class: 'form-control' %> 
    </div> 
    <div class="form-group"> 
     <%= f.label :job_title %> 
     <%= f.select :job_title, ['Developer', 'Entrepreneur', 'Investor'], {}, class: 'form-control' %> 
    </div> 
    <div class="form-group"> 
     <%= f.label :phone_number %> 
     <%= f.text_field :phone_number, class: 'form-control' %> 
    </div> 
    <div class="form-group"> 
     <%= f.label :contact_email %> 
     <%= f.text_field :contact_email, class: 'form-control' %> 
    </div> 
    <div class="form-group"> 
     <%= f.label :description %> 
     <%= f.text_area :description, class: 'form-control' %> 
    </div> 
    <div class="form-group"> 
     <%= f.submit "Update Profile", class: 'btn btn-primary' %> 
    </div> 
    <% end %> 
</div> 

配置/区域设置/ routes.rb中

Rails.application.routes.draw do 
    devise_for :users, controllers: { registrations: 'users/registrations' } 
    resources :users do 
    resource :profile 
    end 
    resources :contacts 
    get '/about' => 'pages#about' 
    root 'pages#home' 
end 
+0

看起来错误是来自设计?如果是这样,你需要按照自述文件中关于如何正确设置设计的设计宝石。 – trueinViso

+0

显示您的路线,请 –

+0

对不起。路线添加。 @trueinViso:这是因为设计? –

首先,没必要包括文件夹

控制器/用户/ profiles_controller内部控制器。 rb

,除非你正在使用的命名空间

当你这样做,你应该命名空间的路线是这样

namespace :users do 
    resources :profiles 
end 

和你的控制器会是这样

class Users::ProfilesController < ApplicationController 
    def new 
    # form where a user can fill out their own profile. 
    @user = User.find(params[:user_id]) 
    @profile = @user.build_profile 
    end 
end 

那怎么使用命名空间。

现在对你的问题,首先尝试移动profiles_controller.rb以高达控制器文件夹这样

控制器/ profiles_controller.rb的用户文件夹下

移动配置文件/ new.html.erb 。让它的应用程序/视图/用户/型材/ new.html.erb

或者

移动控制器出用户的命名空间的

我活该挨打为此而对于错误的原因是我的查看/配置文件文件夹被错误地键入为“profliles”!我纠正它,现在页面渲染正常。感谢您对此的所有帮助。我现在要把我的头放在沙滩上......