first evented steps

This commit is contained in:
2012-11-27 15:31:31 +01:00
parent e65dc584a4
commit 3da9dc68d7
9 changed files with 53 additions and 24 deletions
+7 -1
View File
@@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base
def layout_by_resource
if devise_controller?
case session[:user_return_to]
when /\/user\// then 'phone'
when /\/user\// then ''
when /obtain_token/ then 'obtain_token'
else 'theme1'
end
@@ -49,4 +49,10 @@ class ApplicationController < ActionController::Base
message = args.first || ''
{ok: true, message: message}.merge(options).to_json
end
def broadcast_user(uid, event, data = {})
message = {channel: channel, data: {event: event, data: data}}
uri = URI.parse("http://localhost:9292/faye")
Net::HTTP.post_form(uri, :message => message.to_json)
end
end
+3
View File
@@ -87,6 +87,9 @@ class SupplierController < ApplicationController
def close_list
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
@list.close!
for user_id in @list.user_ids
broadcast_user user_id, 'list_closed', @list
end
render nothing: true
end