-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trilogy.connect
not working in Staging and Production environments.
#149
Comments
Is your production database available via a socket file on that same host? It looks like your configuration may still have Trilogy connecting via a file-based socket rather than remotely over the network and/or port |
Thanks for the reply @bensheldon. I don't think that's it because the actual app works just fine. As an example here is my staging environment config: staging:
database: redacted
username: redacted
password: redacted
adapter: trilogy
host: redacted
port: 3306 Is there something special with |
Okay, I narrowed it down a bit. It looks like the That explains why it works in Development, because in Development, you don't need to pass the config and it'll still connect: config = Rails.configuration.database_configuration[ Rails.env ]
Trilogy.new( config )
#=> <Trilogy:0x000000013a9de1e0
Trilogy.new
=> #<Trilogy:0x0000000139ef01e8 If I supply the named parameters manually it works: Trilogy.new( host: redacted, port: 3306, username: redacted, password: redacted )
=> #<Trilogy:0x00007f676bbf79d8 I tried using splat ( Trilogy.new( **config )
.../trilogy-2.6.1/lib/trilogy.rb:18:in `_connect': No such file or directory - trilogy_connect - unable to connect to /tmp/mysql.sock (Trilogy::SyscallError::ENOENT) Any idea how to pass the |
Okay, figured it out. This ended up working: Trilogy.new( config.symbolize_keys )
#=> #<Trilogy:0x00007f676ba2a790 Is this something you can or want to handle in the library itself so it treats |
Oh! Nice find! I'd like that configuration to be more permissive and less surprising. It looks like we're already duping the connection options during initialization, so maybe that could do the symbolize keys too (with some slight reordering): trilogy/contrib/ruby/lib/trilogy.rb Lines 10 to 23 in 90d81d2
Edit: I misunderstood what we're doing with |
Yup, I would just symbolize the keys for Do you want to handle it or do you want me to submit a PR? |
@joshuapinter if you could submit a PR, I can take it from there 👍🏻 |
@bensheldon There ya go! #151 Thanks. |
In Staging and Production
In Development
The configs between the environments are similar with just different
database
,username
,password
andhost
values.Moreover, the actual Rails application (i.e.
ActiveRecord
) works just fine in all environments using Trilogy.Any thoughts on this?
Thanks!
The text was updated successfully, but these errors were encountered: