2016-04-03 41 views
0

我是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:這是因爲設計? –

回答

1

首先,沒必要包括文件夾

控制器/用戶/ 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的用戶文件夾下

0

移動配置文件/ new.html.erb 。讓它的應用程序/視圖/用戶/型材/ new.html.erb

或者

移動控制器出用戶的命名空間的

1

我活該捱打爲此而對於錯誤的原因是我的查看/配置文件文件夾被錯誤地鍵入爲「profliles」!我糾正它,現在頁面渲染正常。感謝您對此的所有幫助。我現在要把我的頭放在沙灘上......