Activity
Hey Jeff,
Have you seen this episode? https://gorails.com/episodes/scheduling-posts It does this without extra complication.
Otherwise you could use a background job or cron job to toggle it, but that's probalby overkill unless you can't use the above option for some reason.
Posted in Setup Windows 10 Discussion
Alberto, yep. You'll always need libpq-dev to compile the C extension for Ruby to talk to Postgres. 👍
Make sure your User validations are passing. We only validate the email and password in this example so if you've required other fields, your User won't be saved.
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.
Luckily HTML is valid Markdown, but like you see above, you can't really have Markdown in HTML because the characters will be escaped.
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.
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
Posted in Rails Application Templates Discussion
Posted in Rails Application Templates Discussion
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.
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.
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
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.
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.
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???
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.