diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 0a31a46044ce8d0cf609384135de7e24f1404c35..785f2032029c35c1a4fac984a6b568fecfc531c2 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -4,6 +4,9 @@ class CommentsController < ApplicationController def create target = Post.first(:id => params[:comment][:post_id]) text = params[:comment][:text] + puts params.inspect + + if current_user.comment text, :on => target render :text => "Woo!" else diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml index 374f585e5c4a9385158b9bb4e23106ed1cf3652e..50af2117802773072e560eaf06edefef19d5406a 100644 --- a/app/views/comments/_comments.html.haml +++ b/app/views/comments/_comments.html.haml @@ -1,5 +1,5 @@ %div.comments - = render "comments/new_comment", :post => post + /= render "comments/new_comment", :post => post %ul.comment_set - for comment in post.comments = render "comments/comment", :comment => comment diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml index b377602e3165f7e5b121f3adb0e6d9b913ff9752..7cfc43756f58cbd58fa5f4846164dc31d7556034 100644 --- a/app/views/comments/_new_comment.html.haml +++ b/app/views/comments/_new_comment.html.haml @@ -1,6 +1,6 @@ -= form_for Comment.new, :remote => true do |f| - = f.error_messages += form_tag("/comments",:remote => true, :class =>"new_comment", :id => "new_comment") do %p - = f.text_field :text, :value => "dislike!" - = f.hidden_field :post_id, :value => post.id - = f.submit 'comment', :class => 'button' + = text_field_tag "comment_text", 'dislike!', :size => 30, :name => 'comment[text]' + = hidden_field_tag "comment_post_id", "#{post.id}", :name => "comment[post_id]" + = submit_tag 'comment', :id => "comment_submit", :name => "commit" + diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index a0dc4336be8d41e1efdd4edb26acf95c1cc5a251..f9ec3c03bf894b97d5f65fbbda4c53eb0e477c36 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -3,7 +3,7 @@ = link_to_person post.person = post.message %div.time - = link_to "#{time_ago_in_words(post.updated_at)} ago", status_message_path(post) + = link_to(how_long_ago(post), status_message_path(post)) = render "comments/comments", :post => post - if mine?(post) = link_to 'Destroy', status_message_path(post), :confirm => 'Are you sure?', :method => :delete diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index de5eb3f3c1231e736d8f4024ff1c97e5b7da98c4..b3542cf3400892562ca271400754a997869b4b34 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -10,6 +10,7 @@ module WebSocket class << @view include ApplicationHelper include Rails.application.routes.url_helpers + include ActionView::Helpers::FormTagHelper end end @@ -29,8 +30,15 @@ module WebSocket end def self.view_hash(object) - v = WebSocket.view_for(object) - puts v + begin + puts "I be working hard" + v = WebSocket.view_for(object) + puts v.inspect + rescue + puts "in failzord " + v .inspect + raise "i suck" + end + {:class =>object.class.to_s.underscore.pluralize, :html => v} end diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 6fb15dfbee3f9b761cc963f9f997f82aae105b7c..8a7845e4fcacf15a718c93ec04da849ce13b3388 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -1,7 +1,3 @@ -# require 'addressable/uri' -# require 'eventmachine' -# require 'em-http' - class MessageHandler NUM_TRIES = 3 @@ -17,6 +13,9 @@ class MessageHandler def add_post_request(destinations, body) + puts "yay" + puts destinations.inspect + puts body.inspect destinations.each{|dest| @queue.push(Message.new(:post, dest, body))} end @@ -25,7 +24,7 @@ class MessageHandler case query.type when :post http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body} - http.callback {puts query.inspect; process} + http.callback {puts query.body; process} when :get http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT http.callback {send_to_seed(query, http.response); process} @@ -34,6 +33,7 @@ class MessageHandler end http.errback { + puts query.destination + " failed!" query.try_count +=1 @queue.push query unless query.try_count >= NUM_TRIES process