Chris Oliver

Joined

296,490 Experience
100 Lessons Completed
295 Questions Solved

Activity

Posted in How do I sort values incoming from an API call?

Hey Chantal,

You would just use regular Ruby sort_by or sort_by! to sort the array that you get back from the API. https://apidock.com/ruby/Enumerable/sort_by
Awesome, Abraham! Thanks for sharing!

Posted in Rails Application Templates Discussion

You're all good, easy to overlook those things sometimes! :D

Posted in Rails Application Templates Discussion

Like the error mentions:
07:55:57 sidekiq.1 | Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)

Make sure you have Redis installed and running. Anytime you have a connection refused for any service like Postgres, MySQL, Redis, etc, it means it's not running. 

Posted in Doorkeeper Omniauth OAuth Client Discussion

Thanks for the heads up! What a pain in the butt.
Since the models are shared with ALL uploads, if you extend say ActiveStorage::Attachment, all attachments will have that functionality even though they might not need it.

ActiveStorage is quite a different approach than the other file uploading tools like Shrine. Plus it's fairly early right now and some of the functionality only works well with images (namely the variants stuff) which gets annoying if you want to do things like extend AS to make for transcoding video easier or whatever.
Hey Aaron,

You just put the queues in your config/sidekiq.yml file. 👍

https://github.com/mperham/sidekiq/blob/master/examples/config.yml

Posted in Rails Application Templates Discussion

Hey Lee,

You need to include the other lines as well after the error because that's what we use to debug what went wrong. Without it, we can't tell what happened.
Hey Aaron,

At a high level:

You'd need something to sort by. You could modify the ActiveStorage models and add a column to sort by.

Or you could just keep an array of the attachment IDs for those on your model.

Either way would work, but I would probably prefer the second option. Once you have the attribute to sort by, you just grab the attachments order by the sort order that's saved.
Hey Stephen,

So what I did was mimicked Github's Notifications section on Issues. You can see it on the forum here at the bottom of the right sidebar.

Here's what my model looks like. Basically, this tracks who opts in and who opts out. Then we can send the notifications accordingly. 

```ruby
# == Schema Information
#
# Table name: forum_subscriptions
#
#  id                :integer          not null, primary key
#  forum_thread_id   :integer
#  user_id           :integer
#  subscription_type :string
#  created_at        :datetime         not null
#  updated_at        :datetime         not null
#
# Indexes
#
#  index_forum_subscriptions_on_forum_thread_id  (forum_thread_id)
#  index_forum_subscriptions_on_user_id          (user_id)
#

class ForumSubscription < ApplicationRecord
  belongs_to :forum_thread
  belongs_to :user

  scope :optin, ->{ where(subscription_type: :optin) }
  scope :optout, ->{ where(subscription_type: :optout) }

  validates :subscription_type, presence: true, inclusion: { in: %w{ optin optout } }
  validates :user_id, uniqueness: { scope: :forum_thread_id }

  def toggle!
    case subscription_type
    when "optin"
      update(subscription_type: "optout")
    when "optout"
      update(subscription_type: "optin")
    end
  end
end
```

When sending notifications you'll want to build up the list of users like so:

1. All the users who posted in the thread
2. Add all the users who opted in to receive notifications for the thread
3. Remove all the users who opted out
4. Profit???

Posted in How to use rails and sortable connected lists

Hey Graeme, 

Did you see the Trello series? We cover moving between multiple lists in that. It'd be slightly different code since it's in Vue.js but the concept would be all the same. You would need a List model and association to keep track like you mentioned.

Posted in A newbie to Ruby

Try starting with the episode #1.

Posted in Setup Windows 10 Discussion

Bagus, it should be called "software-properties-common" now or "python3-software-properties". Making an update for that.

Posted in Repost / Retweet / Reblog Discussion

Great to hear Dan! Let me know if there are any other features like this you'd like to see!

Posted in How do we request a new video?

Hey Abram,

Not really at the moment. Most people post ideas here, in Slack, or email me. That's something I should build though.

Have any good ideas to share? :D

Posted in Hatchox deploy

Oh gotcha. Well I'd recommend using the Support tab in Hatchbox instead to file tickets so we don't accidentally share things publicly on the forum.

I'll take a look at your account.

Posted in Hatchox deploy

I don't believe that your IP address can start with a 0. You should make sure you have the correct IP.

Posted in Using Webhooks with Stripe Discussion

All you do is grab the signing secret from your Stripe account and set that variable like you would do with the other keys. Link to how to use it is here: https://github.com/integrallis/stripe_event#authenticating-webhooks-with-signatures

I'll do a quick episode on this shortly!

Posted in Simple form survey and dashboard illustration

Welcome! 👋

I don't know of any tutorials that do exactly something like this, but it sounds kind of like survey software maybe?

A few of the details will depend on how you want the app to work. Do you want ot have free form text answers for the questions or multiple choice or something different?

Will the questions be the same for everyone? Will they be configurable (like you can add / remove questions dynamically or will they always be the same)?

For the user dashboard, are you looking to show the same questions and the user's selected answers? Or something else?

Let us know and we can guide you through what you'd need to do!

Posted in Few Big Models or Many Smaller Namspaced models?

🙌 You're welcome!

As for the forms, you can just set the site in a hidden field. @page = Page.new(site: "google") for example.

Remember that your controllers don't have to directly map to models so you could have a controller for Google, separate from your Facebook one, and so on. Then you can have views that are unique so that you can have different designs, instructions, etc for each one.