新手问题 用了 Devise 以后,出现 Routing Error 如何知道错在哪里?

kenneth · 2012年06月21日 · 最后由 u1331878576 回复于 2012年08月01日 · 3000 次阅读

在 3000 端口正常,但是 apache passenger 下跑就出错,不知道什么原因?

帖 routes.rb 看看

Appfp::Application.routes.draw do
  devise_for :users

  get 'kindeditor/images_list'

  post 'kindeditor/upload'

  resources :apps

  root :to => 'apps#index'

end

我昨天也突然碰到 Devise 2.1.2 版的这个问题,查了代码,似乎要加 user_signed_in? 到 current_page 之前,最终原因不明……

<li class="nav-header">SAP Purchase Order</li>
  <li class="<%= 'active' if user_signed_in? and current_page? :controller => 'sap_pos', :action => 'new' %>"><%= link_to "Receive PO Parts", new_sap_po_path %></li>

我的 ApplicationController 中的代码:

class ApplicationController < ActionController::Base
  protect_from_forgery
  before_filter :authenticate_user!
end

#2 楼 @kenneth 下次,最好不要把注释代码发出来

Routing Error 错误贴出来,看看

@ery 注视去掉了 Routing Error

No route matches [GET] "/" Try running rake routes for more information on available routes.

错误信息是 No route matches [GET] "/" 可是路由设置中有 root :to => 'apps#index' 我想不明白.... 关注一下

我什么修改都没有,尽然好了,我崩溃了,啥原因都没有好了。http://www.appfp.com/

#8 楼 @kenneth 莫名奇妙的问题,他的解决方案往往也是莫名其妙的。

#3 楼 @ericguo 昨天我也遇到这个问题了,加上 user_signed_in?果然就对了,但是我并不需要 user_signed_in,最后我的解决方法是把 current_page 换成了<%= 'active' if params[:controller] == 'home' %>,这样凡是在 home_controller 下的页面都会有 active,应该还可以加参数定位到某个 action 上面

需要 登录 后方可回复, 如果你还没有账号请 注册新账号