igorkasyanchuk / rails_db

Rails Database Viewer and SQL Query Runner
https://www.railsjazz.com/
MIT License
1.46k stars 111 forks source link

Issue if root not specified in the routes.rb file #41

Closed freibuis closed 8 years ago

freibuis commented 8 years ago

Not really an issue with RAILS_DB but probably with rails core.

if the root is not specified in the user rails routes.rb file rails_db errors out with (seems to only effect rails engines) undefined method `root_url' for #ActionDispatch::Routing::RoutesProxy:0x0000000683d848

https://github.com/igorkasyanchuk/rails_db/blob/master/app/views/rails_db/shared/_header.html.erb#L44

link_to main_app.root_url <-- doesnt exist so error happens.

easy fix..

get the user to add the following lines to their routes.rb file

Rails.application.routes.draw do
  root 'somecontroller#index'
end

hope this helps any one else that just created a brand new app and scratches there heads why it doesn't work

igorkasyanchuk commented 8 years ago

I see, yes, I think fix would be - if root_url exists than use it, otherwise redirect to root path of engine, e.g. rails_rb.root_url (something like that)

Could you please make a PR with this fix?

freibuis commented 8 years ago

:+1: will do.