I built an app in rails and it works fine on localhost, but when I push to heroku, the routes get messed up. My routes.rb is as follows:
get "pages/index"
get "sessions/new"
resources :posts, :users
match '/posts/new', to: 'posts#new'
match '/posts/create', to: 'posts#create'
match '/posts/:id', to: 'posts#show'
match '/posts/index', to: 'posts#index'
match '/posts/edit/:id', to: 'posts#edit'
match '/posts/destroy/:id', to: 'posts#destroy'
match 'admin', to: 'posts#admin'
match 'login', to: 'sessions#new', :as => :sessions
match '/index', to: 'pages/#about', :as => :index
root :to => 'pages#index'
I want it to root to pages#index, but on heroku the routes are different for whatever reason and it roots to welcome#index.
My local routes
My heroku routes
I deleted the welcome controller, removed it from the routes file, deleted the app on heroku and created a new one.
git remote rm heroku
git add .
git commit -a -m "removed welcome"
heroku create --stack cedar
git push heroku master
heroku run rake db:migrate
I was still getting the root on heroke to be at welcome#index. I tried running the local server in production mode (rails s -e production) and the pages display appropriately. I checked heroku logs and I don't see any errors (aside from DEPRECATION WARNING: You have plugins in vendor/plugins. Support for these plugins will be removed in Rails 4.0, but this doesn't seem to be the error that would be causing the routing issues).
Sounds like an easy problem to fix, but I've tried everything I could think of and everything I read, including deleting the app multiple times and relaunching. Help would be greatly appreciated.
Merge with your master
branch and then push to Heroku. Happens all the time with me.
Good luck.