Skip to content
Extraits de code Groupes Projets
socket_helper.rb 650 octets
Newer Older
  • Learn to ignore specific revisions
  • maxwell's avatar
    maxwell a validé
    module SocketHelper
    
     include ApplicationHelper 
    
    maxwell's avatar
    maxwell a validé
      def obj_id(object)
    
        (object.is_a? Post) ? object.id : object.post_id
    
    maxwell's avatar
    maxwell a validé
      end
      
    
      def url_options
        {:host => "", :only_path => true}
      end
    
    
    maxwell's avatar
    maxwell a validé
      def action_hash(object)
    
    maxwell's avatar
    maxwell a validé
        begin
    
          v = render_to_string(:partial => type_partial(object), :locals => {:post => object}) unless object.is_a? Retraction
    
    maxwell's avatar
    maxwell a validé
    
    
    maxwell's avatar
    maxwell a validé
        rescue Exception => e
    
          puts "web socket view rendering failed for some reason." + v.inspect
    
    maxwell's avatar
    maxwell a validé
          puts object.inspect
          puts e.message
          raise e 
        end
    
    
        {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}.to_json
    
    maxwell's avatar
    maxwell a validé
      end
    
    maxwell's avatar
    maxwell a validé