chrismccord / labrador

A loyal data retriever for your Rails development databases.
http://chrismccord.github.com/labrador/
253 stars 15 forks source link

Labrador::App.initialize: Default @path to @name #21

Closed jdanbrown closed 11 years ago

jdanbrown commented 11 years ago

Without this change I get null paths all over the place on the backend and frontend. It appears that path is simply never supplied.

Am I missing something?

chrismccord commented 11 years ago

I'll review this later this afternoon and will merge if everything looks Ok. I just need to make sure this plays nice with non-session based connections.

chrismccord commented 11 years ago

I'm unable to recreate the null paths on either front end or back end. This includes using both subdomains and manual connections. I believe there could be some bugs when directory names do not map properly to valid subdomains, so I would like to narrow this issue down since we might want to do some manipulation to the name before assigning to path so it is a valid subdomain. Can you verify a few things:

  1. Are you using pow with subdomains, like myapp.labrador.dev or localhost/~/Path/to/App?
  2. Is the name/structure of your app's directory name (if using pow) a valid subdomains?
  3. When you get null errors on the front-end, does the backend also throw an error?

Thanks

jdanbrown commented 11 years ago

Right, I should have pointed out that I wasn't using pow at all, I was just running bundle exec rails s.

I see no errors in the rails console, but when I add debugging output to the code I can observe that app.path is nil, which then gets delivered to the frontend and renders most things useless. In particular:

During all of this I see no ERROR lines in the rails console, but the 500 response reveals another nil error:

Started GET "/data/mysql/schema?collection=view_site_fetches&path=" for 127.0.0.1 at 2013-03-03 14:02:30 -0500
Processing by DataController#schema as */*
  Parameters: {"collection"=>"view_site_fetches", "path"=>"", "adapter"=>"mysql"}
Completed 500 Internal Server Error in 1ms

NoMethodError (undefined method `database' for nil:NilClass):
  app/controllers/data_controller.rb:18:in `schema'

  Rendered /usr/local/Cellar/ruby/1.9.3-p362/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
  Rendered /usr/local/Cellar/ruby/1.9.3-p362/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.4ms)
  Rendered /usr/local/Cellar/ruby/1.9.3-p362/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (10.0ms)

Also from the rails console, each requests triggers a content-length warning, but I assume it's unrelated:

[2013-03-03 14:00:16] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

And here's the first few lines from the rails console:

$ bundle exec rails s -p 8000
=> Booting WEBrick
=> Rails 3.2.11 application starting in development on http://0.0.0.0:8000
=> Call with -d to detach=> Ctrl-C to shutdown server
[2013-03-03 13:53:50] INFO  WEBrick 1.3.1
[2013-03-03 13:53:50] INFO  ruby 1.9.3 (2012-12-25) [x86_64-darwin12.2.0]
[2013-03-03 13:53:50] INFO  WEBrick::HTTPServer#start: pid=79099 port=8000

Started GET "/" for 127.0.0.1 at 2013-03-03 13:53:53 -0500
Processing by PagesController#home as HTML
Redirected to http://localhost:8000/sessions/new
Completed 302 Found in 5ms

Started GET "/sessions/new" for 127.0.0.1 at 2013-03-03 13:53:53 -0500
Processing by SessionsController#new as HTML
  Rendered sessions/new.html.erb within layouts/application (10.7ms)
Compiled i18n/translations.js  (9ms)  (pid 79099)
Compiled application.js  (206ms)  (pid 79099)
Completed 200 OK in 339ms (Views: 338.3ms)
Started GET "/assets_dev/bootstrap.css?body=1" for 127.0.0.1 at 2013-03-03 13:53:54 -0500
Served asset /bootstrap.css - 304 Not Modified (11ms)
[2013-03-03 13:53:54] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

Started GET "/assets_dev/underscore.js?body=1" for 127.0.0.1 at 2013-03-03 13:53:54 -0500
Served asset /underscore.js - 304 Not Modified (2ms)
[2013-03-03 13:53:54] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

...

Let me know if there's more env or log info that would be helpful. I'm not familiar with rails, so I'm probably just doing something silly.

chrismccord commented 11 years ago

Thanks for such a detailed response! I reviewed this and was easily able to recreate it under the straight rails server setup. I should have tried that the first time. Your initial description + solution was perfect actually. Merging now. Much appreciated.