2012-04-18 56 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