Rodrigo Argumedo

Joined

3,480 Experience
34 Lessons Completed
0 Questions Solved

Activity

Posted in How to use Hotwire in Rails Discussion

You can safely delete the files if you are not going to use Webpacker at all.

Posted in How to use Hotwire in Rails Discussion

You can pass in 'Rails new my_app --skip-webpack-install' to create the app framework and skip Webpacker altogether.

Posted in Group Chat with ActionCable: Part 4 Discussion

Starting at around 12:29, you were talking about the MessageRelayJob for broadcasting the message and chatroom#id into the job. So, what I am trying to say is let's say that the user wants to know if the message sent out into the channel but says it does not not return anything. Looking at the sever log views, would it be technically correct to display the user's username (if provided in the User model) instead of ID and as well as other methods provided for the user when troubleshooting chat history?

Example:


Class MessageRelayJob < ApplicationJob
def perform(message)
ActionCable.server.broadcast "chatrooms:#{message.chatroom.id}", {

message: MessagesController.render(message),
chatroom_id: message.chatroom_id
# Display the User ID or username (if defined and not nil)
user: current_user.username ||= current_user.id

end

end

Even though, it successfully connects to the websocket and is listening to the specific channel.

Posted in Group Chat with ActionCable: Part 4 Discussion

As for message relay jobs matter for this particular subject of this ActionCable example, do you recommend putting down for its current_user's id or name in these kind of scenarios when it comes to logging down for the Message job queue and delivering it to Sidekiq?

I found a gotcha to be aware for everyone who is/were watching this episode. When upon calling @mention into the post and click on the referenced username, it will return a invalid number ID instead of the username ID.

I made some changes to the User controller ruby code. To get your username referenced in the URL like /users/yourusernamehere, you will need to the following changes:

In your db/migrate/[datetime-stamp]_create_users.rb:

line 4: create_table :user, id: false do # add this id method into your file before migrating

In app/models/user.rb:

[new line] line 2: self.primary = 'username'

In config/routes.rb:

resources :users, param: :username # add this line as well.

In app/controllers/users_controller.rb:

def user_params
User.find(params[:username]) # alter :id with username
end

And that should work for everyone! (p.s: you will need to reset your database if you migrated before aka rake db:reset)

Will be a free or pro episode for this upcoming one?

As @excid3:disqus said before, see Rails/I18n for local_time gem documentation here: https://github.com/basecamp...