2015-03-19 73 views
0

我有一個包含從我改名色器件默認視圖中的兩個泛音一個登入查看: 1. _sign_in.html.erb 2. _forgot.html.erb鐵路設計sign_up/forgot_password在同樣的觀點 - 錯誤

我重寫色器件密碼控制器:

class PasswordsController < Devise::PasswordsController 
    def create 
    # super 

    self.resource = resource_class.send_reset_password_instructions(resource_params) 
    yield resource if block_given? 

    if successfully_sent?(resource) 
    respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name)) 
    else 
    render signin_path 

    # Original redirect 
    # respond_with(resource) 
    end 
end 
end 

的部分碼:

<%= simple_form_for(resource, as: resource_name, url: user_password_path(resource_name), html: { method: :post }) do |f| %> 
    <%= f.error_notification %> 

    <div class="form-inputs"> 
    <%= f.input :email, required: true, autofocus: true, placeholder: 'Please enter your email address', label: false %> 

<div class="form-actions"> 
    <%= f.button :submit, "Send me instructions to reset my password ", class: "btn-wide secondary" %> 
    </div> 
<% end %> 

下面是這兩個諧音從呈現signin.html.erb觀點:

<div class="hero"> 
    <%= image_tag("key-logo.png", :class => "logo", :alt => "key-logo") %> 
    <h1>App.title</h1> 
    <div class="sign-in"> 
    <%= render "devise/sessions/sign_in" %> 
    </div> 
</div> 
<div class="sign-up"> 
    <div class="intro"> 
    <h1><a name="signupform">Forgot your password?</a></h1> 
    <h3>Don't worry it happens to the best of us. We got this.</h3> 
    <h5>Just enter your email in the form below and you're set!</h5> 
    </div> 
    <div class="row"> 
    <div class="forgot"> 
     <%= render "devise/passwords/forgot" %> 
    </div> 
    </div> 
</div> 

而且我accordlingly配置的路由:

Rails.application.routes.draw do 
    devise_for :users, controllers: { 
    registrations: 'registrations', 
    passwords: 'passwords' 
    } 

    get 'pages/index' 
    get 'docs', to: 'pages#docs', as: 'docs' 
    get 'signin', to: 'pages#signin', as: 'signin' 

    root to: 'pages#index' 
end 

我已經配置application.helper中的設計用戶範圍爲:

module ApplicationHelper 
    # Fix to get devise forms working within the application scope and not just the gem: 
    # http://pupeno.com/2010/08/29/show-a-devise-log-in-form-in-another-page/ 
    def resource_name 
    :user 
    end 

    def resource 
    @resource ||= User.new 
    end 

    def devise_mapping 
    @devise_mapping ||= Devise.mappings[:user] 
    end 

    def day 
    @day = Time.now 
    @day.strftime('%A') 
    end 

end 

當我提交我得到一個缺少模板錯誤:

Missing template /signin with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * 

我知道色器件規格狀態,重新創建views目錄對應的視圖。我試過了,仍然出現錯誤。我想知道這是否與表單命名空間有關。我正在使用simple_forms來呈現我的表單。

回答

0

正是憑着這是一個問題的路線

get 'signin', to: 'pages#signin', as: 'signin' 

當我改回了原來的

get 'pages/signin' 

它的工作