0

We successfully deployed our rails 3.1.4 app to suburi /by on ubuntu 12.04 running nginx. In production.rb we set:

RAILS_RELATIVE_URL_ROOT="/by"

We can login and get to the main menu. However all routes redirected by our custom view_handler in main menu does not work. The purpose of the view_handler is to memorize the next path the app is going to route into and remember how to back up (like the 'back'). Here is the code (relevant code)

  def view_handler
    index  = params[:index].to_i
    url = params[:url]
    if index == 1   #forword
      session[:page_step] += 1 
      session[('page' + session[:page_step].to_s).to_sym] = url
    end

    #redirect to the page by url  
    redirect_to url
  end 

Here is the link_to that does not work anymore (404 not found error):

<%= link_to 'Projects', "/view_handler?index=1&url=#{projects_path}" %>

The displayed URL (not correct. Return 404 not found) is:

http://154.248.209.181/view_handler?index=1&url=/by/projects

The following is the working URL for the above (manually entered):

http://154.248.209.181/by/projects

It seems odd to us that project_path returns '/by/projects' by view_handler. Only 'projects' should be returned for projects_path (by rake routes).

Before deploying to suburi, the rails 3.1.4 app was deployed and worked fine in root directory.

What's could be wrong with our setup? Thanks so much.

4

1 回答 1

0

The broken routes could be fixed with addition of "/by/" before view_handler. Now the link_to looks like:

<%= link_to 'Projects', "/by/view_handler?index=1&url=#{projects_path}" %>

AlsoRAILS_RELATIVE_URL_ROOT="/by" was removed in production.rb. It seems no use.

于 2012-05-07T15:17:43.523 回答