修改redmine默认页面遇到问题

参考使用: 

修改redmine默认页面   方法二。

自己犯二了,“在require_login的respond_to那一行之上加上” 理解出错,开始任务加在respone_to的里面。

 

后来细看,自己二了,理解错了,他的意思放在respond_to这行的上面添加:

 

 

if url.rindex("/") == url.length -1
   url = url_for(:controller => "my", :action => "page")
 end
 

然后,添加在responed_to 的上面,出现如下log信息:

 

 

log:

 

s&)' (Client.h:742)

     in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&)' (Hooks.cpp:294)

     in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:563)

 

[ pid=29699 thr=23733029794220 file=utils.rb:176 time=2012-11-30 15:47:49.490 ]: *** Exception SyntaxError in PhusionPassenger::ClassicRails::ApplicationSpawner (/home/scm/redmine-1.4.4-0/apps/redmine/htdocs/app/controllers/application_controller.rb:199: syntax error, unexpected tUMINUS_NUM, expecting kTHEN or ':' or '\n' or ';'

 if url.rindex("/") == url.length -1

                                   ^

/home/scm/redmine-1.4.4-0/apps/redmine/htdocs/app/controllers/application_controller.rb:569: syntax error, unexpected kEND, expecting $end) (process 29699, thread #):

        from /home/scm/redmine-1.4.4-0/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:184:in `require'

 

======================logs  end=============================

sovle:

reference ---> syntax error, unexpected tIDENTIFIER, expecting kEND

 

原因: 1、 if url.rindex("/") == url.length -1 的“-1”之前都了一个空格

最后的代码:
  def require_login
    if !User.current.logged?
      # Extract only the basic url parameters on non-GET requests
      if request.get?
        url = url_for(params)
      else
        url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
      end
      if url.rindex("/") == url.length-1
         url = url_for(:controller => "my", :action => "page")
      end
      respond_to do |format|
        format.html { redirect_to :controller => "account", :action => "login", :back_url => url }
        format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
        format.xml  { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
        format.js   { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
        format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
      end
      return false
    end
    true
  end
 

====================== end  ok  =============================

 

 

 


 

你可能感兴趣的:(redmine)