Gareth Gomersall

Joined

30 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Group Chat with ActionCable: Part 4 Discussion

found it! :)

my message_relay_job.rb file was showing:


message: MessageController.render(message)

instead of:


message: MessagesController.render(message)

It's working a treat now :)

Posted in Group Chat with ActionCable: Part 4 Discussion

Hey Chris, i've been following the videos for the group chat and so far they're awesome (as are all the videos of yours that i've watched).
I've run into a bit of a stale point though, in your video around 15:31 we're logging the message data to the console, but seems it's not working for me, nothing is printing to the chrome console.

my rails server output is showing:


[ActionCable] [User 2] ChatroomsChannel is streaming from chatrooms:2
Started POST "/chatrooms/1/messages" for ::1 at 2016-10-16 14:45:53 +0100
Processing by MessagesController#create as JS
Parameters: {"utf8"=>"✓", "message"=>{"body"=>"show me"}, "chatroom_id"=>"1"}
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 2], ["LIMIT", 1]]
Chatroom Load (0.1ms) SELECT "chatrooms".* FROM "chatrooms" WHERE "chatrooms"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
(0.0ms) begin transaction
SQL (0.4ms) INSERT INTO "messages" ("chatroom_id", "user_id", "body", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["chatroom_id", 1], ["user_id", 2], ["body", "show me"], ["created_at", 2016-10-16 13:45:53 UTC], ["updated_at", 2016-10-16 13:45:53 UTC]]
(7.4ms) commit transaction
[ActiveJob] Enqueued MessageRelayJob (Job ID: a83d7365-8e56-4ea6-a03f-db172f5b1c62) to Async(default) with arguments: #<globalid:0x007ff34bd10358 @uri="#&lt;URI::GID" gid:="" slack-clone-rails5="" message="" 16="">>
Message Load (0.3ms) SELECT "messages".* FROM "messages" WHERE "messages"."id" = ? LIMIT ? [["id", 16], ["LIMIT", 1]]
Rendering messages/create.js.erb
[ActiveJob] [MessageRelayJob] [a83d7365-8e56-4ea6-a03f-db172f5b1c62] Performing MessageRelayJob from Async(default) with arguments: #<globalid:0x007ff34c393810 @uri="#&lt;URI::GID" gid:="" slack-clone-rails5="" message="" 16="">>
Rendered messages/create.js.erb (0.6ms)
Completed 200 OK in 113ms (Views: 26.6ms | ActiveRecord: 8.0ms)

[ActiveJob] [MessageRelayJob] [a83d7365-8e56-4ea6-a03f-db172f5b1c62] Chatroom Load (0.1ms) SELECT "chatrooms".* FROM "chatrooms" WHERE "chatrooms"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
[ActiveJob] [MessageRelayJob] [a83d7365-8e56-4ea6-a03f-db172f5b1c62] Performed MessageRelayJob from Async(default) in 31.33ms


************
Which seems all good, just wondered if you had any input why this wouldn't be showing the console.log data

chatrooms.coffee:


App.chatrooms = App.cable.subscriptions.create "ChatroomsChannel",
connected: ->

disconnected: ->

received: (data) ->
console.log data

message_relay_job:


class MessageRelayJob < ApplicationJob
queue_as :default

def perform(message)
ActionCable.server.broadcast "chatrooms:#{message.chatroom.id}", {
message: MessageController.render(message),
chatroom_id: message.chatroom.id
}
end
end

chatrooms_channel:


class ChatroomsChannel < ApplicationCable::Channel
def subscribed
current_user.chatrooms.each do |chatroom|
stream_from "chatrooms:#{chatroom.id}"
end
end

def unsubscribed
stop_all_streams
end
end

not sure what else you would need to check? if you need my repo it's here
https://github.com/ggomersa...

Hope you can help :)

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

Hey Chris and Magzhan,

I've got the same problem at the moment with my nibli site (chris you'll remember doing the code cast for me:) )

I've check the production.log but nothing there, i've also checked the /var/log/nginx/error.log and it's got something to do with the table lead

App 2163 stdout: Processing by PagesController#index as HTML
App 2163 stdout: PG::UndefinedTable: ERROR: relation "leads" does not exist
App 2163 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 2163 stdout: ^
App 2163 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 2163 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 2163 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 2163 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 2163 stdout: WHERE a.attrelid = '"leads"'::regclass
App 2163 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 2163 stdout: ORDER BY a.attnum
App 2163 stdout:
App 2163 stdout: PG::UndefinedTable: ERROR: relation "leads" does not exist
App 2163 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 2163 stdout: ^
App 2163 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 2163 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 2163 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 2163 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 2163 stdout: WHERE a.attrelid = '"leads"'::regales
App 2163 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 2163 stdout: ORDER BY a.attnum
App 2163 stdout:
App 2163 stdout: Completed 500 Internal Server Error in 2ms

I thought that when we do the created the database it would do all the tables, how do i register them? do i have to do rake db:migrate?