ryanb / private_pub

Handle pub/sub messaging through private channels in Rails using Faye.
MIT License
864 stars 228 forks source link

Added a configuration file to change the server / secret token depending on the rails environment #6

Closed nhocki closed 13 years ago

nhocki commented 13 years ago

I've added a private_pub.yml file inside the config folder. It will let you change the Faye server and secret token easier depending on the environment.

I have no idea how to create tests for that, I've tested inside a rails app and it worked (using my git repo as the gem source). If you tell me how to write tests depending on the Rails.env, I'll gladly add those.

Also, removed a comma from the reset_config method (after the 60 * 60).

Thanks,

Nicolás Hock Isaza.

ryanb commented 13 years ago

The problem is faye.ru needs to load the initializer file but it does not have a Rails constant or the concept of an environment. However this does bring to attention the problem of using a Ruby initializer file in that it's easy to put Rails specific goodies in there. Even the docs show adding 10.minutes as the signature expiration but that actually won't work in faye.ru.

What we could do is switch over to a yml file entirely to prevent one from using Rails there. This can be automatically loaded when going through Rails, and a load_config method could be provided to use in faye.ru. The ENV["RAILS_EVN"] could be passed in as the environment when going through faye.ru.

nhocki commented 13 years ago

I'll close this now that the other pull request has been submitted. The other one includes this + the changes commented here...