William Murphy

Joined

8,550 Experience
85 Lessons Completed
0 Questions Solved

Activity

Posted in Pagination with will_paginate Discussion

Ohre - you need to remove the space between @ and articles so it is just @articles

Posted in What do you listen to while coding?

I listen to the chill house playlist on Amazon Music - so chill to work to! I find anything poppy distracts me to much.

Hey Tolase,

Assuming your poll_items are scoped to your polls and your likes are scoped to your poll_items you can scope your likes to your polls by adding the following to your polls model:

has_many :likes, through :poll_items

then this will work as expected:

def likes?(poll)
poll.likes.where(user_id: id).any?
end

Hope that helps!

Posted in How do i use a username instead of an email?

Hey Ookma-Kyi

Yes you can, you just need to add a user name column to your users model with a migration:
add_column :users, :user_name, :string

In your user model make sure you add a validation so it is present and unique:

validates :user_name, presence: true, uniqueness: true

In your signup form make sure you add a user_name field:

<%= f.text_field :user_name %>

And then when the user signs in, in your create session controller action search for the user by user_name rather than email:

User.find_by(user_name: params[:user][:user_name])

Hope that helps!

Posted in Multiuser Live Video Chat in Rails Discussion

Awesome Video! Been desperate to know how to do this.