chrismccord / labrador

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

Access PostgresApp database #2

Closed tompesman closed 12 years ago

tompesman commented 12 years ago

Hello,

Nice project!

I'm running into a problem with some of my projects using the http://postgresapp.com/ database.

undefined method `size' for nil:NilClass

The database.yml contains:

adapter: postgresql
host: localhost
database: project_development

Which is enough to connect to the database. Is there something missing for labrador?

chrismccord commented 12 years ago

Can you try adding a blank entries for username and password?

adapter: postgresql
host: localhost
database: project_development
username:
password:

If you don't have any luck there, can try spinning up the app in dev mode and getting a full backtrace of the error:

$ cd ~/.labrador
$ bundle exec rails s

Then you can hit labrador at http://localhost:3000/~/Path/to/your/app

tompesman commented 12 years ago

No luck. This is the part where it's redirected. No real backtrace.

Started GET "/Users/tom/code/project" for 127.0.0.1 at 2012-09-06 15:25:39 +0200
Processing by PagesController#home as HTML
  Parameters: {"path"=>"Users/tom/code/project"}
Redirected to http://localhost:3000/error
Filter chain halted as :find_adapters rendered or redirected
Completed 302 Found in 11m

Another backtrace I've found is this one:

Errno::ENOENT (No such file or directory - /assets/ico):
  lib/labrador/app.rb:18:in `open'
  lib/labrador/app.rb:18:in `entries'
  lib/labrador/app.rb:18:in `find_all_from_path'
  app/controllers/application_controller.rb:48:in `find_applications'

But this looks more like a favicon.

chrismccord commented 12 years ago

Sorry about that. I forgot I'm catching controller errors passively even in dev mode and still rendering the same error page. It looks like this is a nil username problem from the postgres-pr gem as I'm able to recreate it on my end if I leave off a username param:

ruby-1.9.3-rc1 :001 > postgres = Labrador::Postgres.new(host: 'localhost', database: 'project_development')
NoMethodError: undefined method `size' for nil:NilClass
from /Users/chris/.labrador/vendor/bundle/ruby/1.9.1/gems/postgres-pr-0.6.3/lib/postgres-pr/message.rb:479:in `block in dump'

Can you try using a blank string in your yaml config

username: ""
password:

I'll need to handle this on the app side so this isn't necessary, but hopefully that narrows it down.

tompesman commented 12 years ago

Yes it's working! The username for the PostgresApp is the local user (whoami), an empty string is not allowed.

It looks like the postgres adapter handles the missing parameters differently.

chrismccord commented 12 years ago

Closing this one since it will work properly if you include the username credential in your database.yml, which I think is the most common scenario. I'm glad we could get things working!

rdlugosz commented 12 years ago

Just a me too post since this bit me also & I disagree with the assumption that including the username in database.yml is the "most common scenario". For common OSX postgres installs it is not needed (since the adapter automatically uses the current user name) and often omitted.

Thx for a slick tool, btw. This is going to be really handy!

chrismccord commented 12 years ago

@thatRD, @tompesman. I think I was wrong assuming that no username was an edge case. It now defaults to your username (whoami) on master. Please update and let me know if this accommodates your original database.yml. Thanks!

tompesman commented 12 years ago

Thanks! It works flawlessly!

rdlugosz commented 12 years ago

awesome, thx!