Dan*_*her 4 ruby-on-rails devise jquery-mobile ruby-on-rails-3.1
我正在尝试设计登录,但由于缺少模板,我收到了500错误.任何的想法?为什么要渲染devise/sessions/create?
Rails 3.1
我正在使用mobylette gem:https://github.com/tscolari/mobylette 我已经设计了:
config.navigational_formats = [:"*/*", "*/*", :html, :mobile]
Completed 500 Internal Server Error in 145msActionView::MissingTemplate (Missing template devise/sessions/create, application/create with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:mobile], :locale=>[:en, :en]}. Searched in: * "/Users/Armageddon/Projects/Business/jquerymobiletest/app/views" * "/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@jquerymobiletest/gems/devise-1.4.9/app/views"): Rendered /Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@jquerymobiletest/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.5ms)
我必须进行以下更改才能使其工作:
配置/初始化/ devise.rb
config.http_authenticatable_on_xhr = false
不得不犯这个错误,否则jQuery mobile会发送XHR请求登录,你会收到401错误.
config.navigational_formats = [:"*/*", "*/*", :html, :mobile]
否则它将无法识别格式.你认为这会处理重定向但实际上并没有.你还需要做一件事.
这对我来说很糟糕所以我把它添加到:config/initializers/devise_hack.rb
ActionController::Responder.class_eval do
alias :to_mobile :to_html
end
现在它有效.
还有一件事; 在我的application.rb我有这个为mobylette设置我的移动东西:
respond_to_mobile_requests :skip_xhr_requests => false, :fall_back => :html
在Responder.class_eval和:fall_back => :html你之间你认为这些都没有必要.很多配置文件看起来都是一样的,或者是重复的.但是,如果没有所有这些设置,它就无法正常工作.
| 归档时间: |
|
| 查看次数: |
2261 次 |
| 最近记录: |