Skip to content

Commit ae6b41a

Browse files
committedMar 13, 2013
Fixed faye host bug for production
- 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
1 parent 6c2b3fe commit ae6b41a

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed
 

‎app/assets/javascripts/backbone/broadcasters/faye.js.coffee.erb

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
class Kandan.Broadcasters.FayeBroadcaster
22

33
constructor: ()->
4-
@fayeClient = new Faye.Client("http://<%= ActionMailer::Base.default_url_options[:host] %>/remote/faye")
5-
6-
<% if Rails.env == "test" %>
7-
@fayeClient.setHeader('Access-Control-Allow-Origin', '*');
8-
<% end %>
4+
@fayeClient = new Faye.Client("<%= ENV['FULL_HOST'] %>/remote/faye")
95

106
@fayeClient.disable('websocket')
117
authExtension = {

‎config/environments/development.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@
3939
config.logger.level = Logger.const_get(
4040
ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'DEBUG'
4141
)
42-
43-
config.action_mailer.default_url_options = { :host => "localhost:3000" }
42+
4443
end

‎config/environments/test.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@
3535
# Print deprecation notices to the stderr
3636
config.active_support.deprecation = :stderr
3737

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

‎lib/broadcasters/faye.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def broadcast(channel, message)
1313
end
1414

1515
def assets
16-
["http://#{ActionMailer::Base.default_url_options[:host]}/remote/faye.js"]
16+
["#{ENV['FULL_HOST']}/remote/faye.js"]
1717
end
1818
end
1919
end

0 commit comments

Comments
 (0)
Please sign in to comment.