2012-04-18 80 views
1

我有這樣的路線:Ruby on Rails的 - 缺少模板錯誤,當我敢肯定我有模板

scope :module => :mobile, :as => :mobile do 
    constraints(:subdomain => /m/) do 
     devise_for :users, :path => "", :path_names => 
       { :sign_in => "login", :sign_out => "logout", 
       :sign_up => "signup" }, 
       :controllers => {:sessions => "mobile/sessions"} 

     resources :home 

     resources :disclosures # Will have new, get, look up a disclosure 
    end 
    end 

與此控制器:

class Mobile::SessionsController < ApplicationController 
    def create 
    end 
end 

,並在此目錄下:/app/views/mobile/sessions/new.html.haml

這是new.html.haml文件中的代碼:

= content_for :page_title do 
    = t :page_title_login 
= content_for :primary_content do 
    #login_box 
    .span6 
     #traditional-login 
    .span4 
= content_for :before_closing_body_tag do 
    configure_login_form(#{request.xhr?.to_s.downcase}); 

但我登錄後,我得到在瀏覽器這個錯誤:

Missing template mobile/sessions/create, application/create with {:locale=>[:en, :en], :formats=>[:html], :handlers=>[:haml, :erb, :builder]}. Searched in: * "/Users/alexgenadinik/projects/cmply/cmply-app/app/views" * "/Library/Ruby/Gems/1.8/gems/ckeditor-3.6.3/app/views" * "/Library/Ruby/Gems/1.8/gems/kaminari-0.13.0/app/views" * "/Library/Ruby/Gems/1.8/gems/devise-2.0.4/app/views" 

這表明,我認爲該系統認爲我沒有new.html.haml文件。但我顯然擁有該文件。所以我不確定是什麼問題。並想知道我做錯了什麼?

在此先感謝!

回答

3

這裏的錯誤不是你錯過了new.html.haml文件;你缺少一個create.html.haml或遠離create操作的重定向。通常你登錄後重定向,所以試着改變你的控制器動作是這樣的:

class Mobile::SessionsController < ApplicationController 
    def create 
    redirect_to root_url 
    end 
end 

或任何你想要的遊客拉閘。

+0

謝謝,這使得很多感覺:) – GeekedOut 2012-04-18 14:02:54

+0

實際上,我得到了一個錯誤後,這樣做。也許在我的情況下,我不應該重定向到root_url。 root_url在哪裏定義?我將需要重定向到user_home或類似的東西。我跑耙子,但沒有任何路徑看起來像root_url – GeekedOut 2012-04-18 14:06:21

+0

我需要去像我的耙路線中的mobile_home路徑,但是當我這樣做時,我得到一個錯誤,如:未定義的局部變量或方法'mobile_home 'for# GeekedOut 2012-04-18 14:16:20