0

I am trying to upgrade my rails 2.3.14 app to rails 4 but experiencing some issues.

In my routes.rb I have the following general rules defined after the more specific ones:

map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id/:org'
map.connect ':controller/:action/:id.:format'  

map.connect ':action/:id', :controller => "home"

so in the rails 4 equivalent I changed these to

get  ':controller/:action/:id'
get  ':controller/:action/:id/:org'
get  ':controller/:action/:id.:format'  

get  ':action/:id', :controller => "home"

http://localhost:3000/ is still taking me to the default home page, I assume it's because there's no root 'welcome#index' (example from routes.rb file) route but I'm not sure how to achieve that since in my app the home url is defined like so in application_controller.rb

def default_home_url
  if @person
    '/ticket/list/Open'
  elsif request.env["HTTP_REFERER"].include? 'portal'
  '/portal'
  else
    "/"
  end
end

The home_controller.rb #index is

def index
  redirect_to default_home_url if @person
end

and the way that @person is set is in a function named check_user in the application_controller.rb

def check_user
 @person = Person.find(session[:person]) if session[:person]
 @admin = (@person and @person.priviledges == 'admin')
end

This function is called when someone logs in and at the top of application_controller.rb.

So, if I go to http://localhost:3000/ticket/list/Open in the rails 4 app I get this error: NoMethodError in TicketController#list undefined method 'include?' for nil:NilClass and the line highlighted is this one:

elsif request.env["HTTP_REFERER"].include? 'portal'

from application_controller.rb, not ticket_controller.rb so I am thoroughly confused about what's going on.

Apologies if anything is unclear, I can provide more information if needed.

update

Managed to get rid of the error by changing that line to

elsif request.env.try(:include?, 'portal')

so the home url is still taking me to the default rails homepage.

martincarlin87
  • 10,848
  • 24
  • 98
  • 145

1 Answers1

0

managed to solve it, was quite straightforward in the end, just needed the following route:

root 'home#index'
martincarlin87
  • 10,848
  • 24
  • 98
  • 145