Skip to content

Commit

Permalink
Fixed faye host bug for production
Browse files Browse the repository at this point in the history
- Faye now uses and ENV variable only for test env.
- Removed unnecessary access-control-allow for test env
- Removed default_url_for_options for Action Mailer to avoid having to set it on production env
  • Loading branch information
gabceb committed Mar 13, 2013
1 parent 6c2b3fe commit ae6b41a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
class Kandan.Broadcasters.FayeBroadcaster

constructor: ()->
@fayeClient = new Faye.Client("http://<%= ActionMailer::Base.default_url_options[:host] %>/remote/faye")

<% if Rails.env == "test" %>
@fayeClient.setHeader('Access-Control-Allow-Origin', '*');
<% end %>
@fayeClient = new Faye.Client("<%= ENV['FULL_HOST'] %>/remote/faye")

@fayeClient.disable('websocket')
authExtension = {
Expand Down
3 changes: 1 addition & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@
config.logger.level = Logger.const_get(
ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'DEBUG'
)

config.action_mailer.default_url_options = { :host => "localhost:3000" }

end
4 changes: 3 additions & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

config.action_mailer.default_url_options = { :host => "localhost:9292" }
# Variable set to be able to get faye client for test environments
ENV['FULL_HOST'] = "http://localhost:9292"

end
2 changes: 1 addition & 1 deletion lib/broadcasters/faye.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def broadcast(channel, message)
end

def assets
["http://#{ActionMailer::Base.default_url_options[:host]}/remote/faye.js"]
["#{ENV['FULL_HOST']}/remote/faye.js"]
end
end
end
Expand Down

0 comments on commit ae6b41a

Please sign in to comment.