Created
October 10, 2012 23:45
-
-
Save JFickel/3869263 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
>>>>> index.html.haml | |
%h1 Chat | |
%ul#chat | |
= render @chat_messages | |
= form_for ChatMessage.new, remote: true do |f| | |
= f.text_field :content | |
= f.submit "Send" | |
= subscribe_to "/chat_messages/new" | |
>>>>> create.js.erb | |
<% publish_to "/chat_messages/new" do %> | |
$("#chat").append("<%= j render(@chat_message) %>"); | |
<% end %> | |
$("#new_chat_message")[0].reset(); | |
>>>>> chat_messages_controller.rb | |
class ChatMessagesController < ApplicationController | |
def index | |
@chat_messages = ChatMessage.all | |
end | |
def create | |
@chat_message = ChatMessage.create!(params[:chat_message]) | |
end | |
end | |
>>>> server log | |
Started POST "/chat_messages" for 127.0.0.1 at 2012-10-10 18:44:44 -0500 | |
Processing by ChatMessagesController#create as JS | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"JVANuBLJUpXfcNmTKEXvzUaDUgUhzR2MrZ2DGL19kl0=", "chat_message"=>{"content"=>"test"}, "commit"=>"Send"} | |
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 | |
(0.0ms) begin transaction | |
SQL (0.3ms) INSERT INTO "chat_messages" ("content", "created_at", "sender_id", "team_id", "updated_at") VALUES (?, ?, ?, ?, ?) [["content", "test"], ["created_at", Wed, 10 Oct 2012 23:44:44 UTC +00:00], ["sender_id", nil], ["team_id", nil], ["updated_at", Wed, 10 Oct 2012 23:44:44 UTC +00:00]] | |
(0.9ms) commit transaction | |
Rendered chat_messages/_chat_message.html.haml (0.2ms) | |
Rendered chat_messages/create.js.erb (2.8ms) | |
Completed 200 OK in 10ms (Views: 6.4ms | ActiveRecord: 1.5ms) | |
>>>>> inspector result (expecting more?) | |
$("#new_chat_message")[0].reset(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment