1

我有这条路线:

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 文件。但我显然有那个文件。所以我不确定是什么问题。并知道我做错了什么?

提前致谢!!

4

1 回答 1

3

这里的错误不是您缺少 new.html.haml 文件;您缺少 create.html.haml 或远离创建操作的重定向。通常您在登录后重定向,因此请尝试将您的控制器操作更改为以下内容:

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

或者您希望访客结束的任何地方。

于 2012-04-18T14:02:06.660 回答