Created
December 19, 2016 12:01
-
-
Save geniuskidkanyi/944a9739e45fd63b857b55032bbf3235 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def current_user | |
| current_user ||= Chatroom.find cookies.signed[:visitor_id] if cookies.signed[:visitor_id] | |
| if current_user | |
| current_user | |
| else | |
| visitor = Visitor.create!(location: "request.remote_ip", ip: "request.remote_ip") | |
| log_in visitor | |
| chatroom = Chatroom.create!(name: visitor.location) | |
| chatroom_user = chatroom.chatroom_users.where(user_id: visitor.id).first_or_create | |
| end | |
| end | |
| this in the actioncable channel | |
| this the error i get from first line | |
| successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket) | |
| Could not execute command from {"command"=>"subscribe", "identifier"=>"{\"channel\":\"ChatroomsChannel\"}"}) [NameError - undefined local variable or method `request' for #<ChatroomsChannel:0x005612f3b7ccd8> | |
| Did you mean? require]: /home/geniuskid/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/cookies.rb:11:in `cookies' | /home/geniuskid/rails/chatty/app/channels/chatrooms_channel.rb:25:in `current_user' | /home/geniuskid/rails/chatty/app/channels/chatrooms_channel.rb:7:in `subscribed' | /home/geniuskid/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/action_cable/channel/base.rb:236:in `block in subscribe_to_channel' | /home/geniuskid/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:126:in `call' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we want to track a visitor then the simple way of tracking it can be