The websocket server is running in a separate process from the Rails application so to authenticate the user we need cookies. Set up cookies in Devise # app/config/initializers/warden_hooks.rb Warden::Manager.after_set_user do |user,auth,opts| scope = opts[:scope] auth.cookies.signed["#{scope}.id"] = user.id auth.cookies.signed["#{scope}.expires_at"] = 30.minutes.from_now end # app/config/initializers/warden_hooks.rb ... Warden::Manager.before_logout do |user, auth, opts| scope = opts[:scope] auth.cookies.signed["#{scope}.id"] = nil auth.cookies.signed["#{scope}.expires_at"] = nil end ... Configure AC connection # Read More
Month: September 2016
Delete file from git history completely
Run the following code: git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch file-path' Alternatively: git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch app/views/index.html.erb' --prune-empty --tag-name-filter cat -- --all Learn more: http://stackoverflow.com/a/23188613 Read More
Replace rails flash messages with toastr
1. set up toastr 2. add the following code to application.html.erb <% unless flash.empty? %> <script type="text/javascript"> <% flash.each do |f| %> <% type = f[0].to_s.gsub('alert', 'error').gsub('notice', 'info') %> toastr['<%= type %>']('<%= f[1] %>'); <% end %> </script> <% end %> Read More