Chris Oliver

Joined

291,480 Experience
86 Lessons Completed
296 Questions Solved

Activity

Posted in Doorkeeper Omniauth OAuth Client Discussion

Hey Trevor,

That means your raw_info is returning nil. It should be returning an hash {}.

Also I uploaded all the source code for these finally so you can reference my omniauth gem. I think I made some tweaks to it. https://github.com/gorails-screencasts/oauth-api-authentication

I'm not sure it's so worriesome. A markdown editor is super simple so unless there are a ton of bugs, there's not much maintenance that you would need.

That's actually leftover from when I moved away from SimpleMDE. I forgot to remove that. Unfortunately Trix isn't great for code samples so I think I'm going to be migrating back.

Luckily HTML is valid Markdown, but like you see above, you can't really have Markdown in HTML because the characters will be escaped.
You could send them the message with ActionCable right after your PDF code finishes generating the file. You'd have to store the file somewhere and then include the link to it. Probably S3 for storage. 

The problem with deleting the file after the user downloads it is that you then break the link. If they click the link again they'll get a 404 and you'll certainly end up with support calls dealing with that.

With email, you could generate the PDF and just email it over as an attachment. That way you wouldn't have to store a copy of the file and the user can always reference the file as long as they don't delete the email. This would probably be easiest to manage overall if you don't want to store the PDFs permanently on S3.
They're all encrypted. Not sure why you would store anything in plaintext like that.

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