Taylor Cooney


2,050 Experience
2 Lessons Completed
1 Question Solved


Posted in in app notifications using stimulus and ujs

Thanks for the reply Joel. I managed to get the Notifications displaying, and extended the Dropdown Controller from Chris' tailwindcss/stimulus repo - https://github.com/excid3/tailwindcss-stimulus-components

Now I'm in the process of converting the jQuery that you posted to ES6, I was just curious if you had a complete gist/repo of the implementation to compare to!

Posted in in app notifications using stimulus and ujs

Did you ever finish this? I am looking to do the exact same thing.

Posted in How do I insert smart variables with a text editor?


Posted in Delete images with active storage in rails app?

In the link to the Medium article that you reference the code from, there is a section included around deleting the images. Deleting associated avatar is as simple as doing: user.avatar.purge.
What exactly seems to be the issue?

Note: a GoRails user had a similar issue that they posted to StackOverflow: https://stackoverflow.com/questions/52170764/active-storage-purge-method-throws-undefined-method-signed-id-for-nilclass/52171476#52171476

Posted in How do I insert smart variables with a text editor?

I would really appreciate some insight to how you could let a user select from pre-definied variables in a dropdown and insert them into a text area; some people have mentioned saving a liquid and re-rending as a liquid template. I've seen this done numerous times, but this is the cleaniest implementation (https://i.imgur.com/QVCVfYs.pnghttp://)

I believe there is an easier way to implement this. Let me know if you have any experience with something like this.

Hey Vendant...check out Active Storage and the tutorial below. Active Storage allows you to attach files to your Active Record model, such as images.


Posted in Inviting Users with devise_invitable Discussion

I felt close with this one! If you see the trace below it still manages to demote the Owner to a User, and then when trying to promote the User back to an Owner, it throws "Team must have at least one owner", since it just demoted the last and only owner. How can you check that as the only Owner, you can't demote yourself? unless team.team_members.where(role: :owner).exists? will return true.

Member Exists? (0.5ms)  SELECT 1 AS one FROM "members" WHERE "members"."store_id" = $1 AND "members"."role" = $2 LIMIT $3  [["store_id", 1], ["role", 0], ["LIMIT", 1]]
15:15:12 web.1      |   ↳ app/models/member.rb:21:in `store_has_owner'
15:15:12 web.1      |   Member Update (0.4ms)  UPDATE "members" SET "role" = $1, "updated_at" = $2 WHERE "members"."id" = $3  [["role", 1], ["updated_at", "2019-08-26 19:15:12.965431"], ["id", 1]]
15:15:12 web.1      |   ↳ app/controllers/admin/members_controller.rb:39:in `make_user'
15:15:12 web.1      |    (0.6ms)  COMMIT
15:15:12 web.1      |   ↳ app/controllers/admin/members_controller.rb:39:in `make_user'
15:15:12 web.1      | Redirected to http://lvh.me:5000/admin/dashboard
15:15:12 web.1      | Completed 302 Found in 24ms (ActiveRecord: 3.8ms | Allocations: 9037)

Posted in Sidekiq + Action Mailer

Hey Michael..Sidekiq allows you to schedule the time when a job will be executed, and so does Active Job, through deliver_later (https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later). Active Job is integrated with Action Mailer, so try to enqueue the delayed delivery through Active Job instead of Sidekiq.


UsersMailer.remind_email(@user).deliver_later(wait: 2.minutes)

Posted in Inviting Users with devise_invitable Discussion

I've seen this implemented in other apps and I'm trying to extend it. It's not neccesiarly a devise invitable question but a general question using a role attribute.

Take a User that has and belongs to many Stores via a Team join table. A User that owns the Store has an Team role attribute of Owner, and he can invite Team Members to collaborate with restricted permissions via Pundit. Team Members that are invited have a Team role attribute of User (for restricted permissions). An Owner could promote a Team Member from User to Owner status (to gain full permissions over the Store model). An Owner can also demote a Team Member from Owner to User. How can I add a guard to only allow an Owner to be demoted if there is another Owner of the Store? Meaning, a Store could never be left without an Owner. make_user should have some type of return if the current_company.members.owners is equal to or less than 1. What's a logical way to add that guard or is the above sufficient?

def make_owner
    member = current_company.members.find(params[:id])
    member.update_attribute(:role, "owner")
    redirect_to admin_dashboard_path, notice: "#{member.user.email} is now an owner."

  def make_user
    member = current_company.members.find(params[:id])
    member.update_attribute(:role, "user")
    redirect_to admin_dashboard_path, notice: "#{member.user.email} is now a user."

Posted in How do I manage business hours for a store?

Thanks @ChrisOliver. I got it working with your help! I really appreciate it, it seems rather trivial but a core function of my app - also, it seems like between the two of us we've provided the most insight to setting up store hours. I could find limited information around this, again, for what seems to be a trivial feature.

Here is the full gist of the commit...I also added an index to the column using GIN (not listed in the gist).

Let me know if you have any feedback

Posted in Two Factor Authentication With Devise Discussion

Really great Chris. You can even extend this to send SMS quite easily

def pre_otp
    user = User.find_by(otp_params)
    @two_factor_enabled = user && user.otp_required_for_login

    respond_to do |format|
      format.js {
        # Users should be able to receive their one-time password via SMS
        # through a service like Twilio
        @otp = user.current_otp if @two_factor_enabled
        # ...logic to send @otp

Posted in How do I manage business hours for a store?

This still is stumping me; @ChrisOliver could you share a gist possible to shed some more light?

Is this an ActiveStorage::Blob?

Posted in How do I manage business hours for a store?

Ah, this is great insight. To clarify, you setup 14 columns on the model, leaving a Store model with a number of columns around their operating hours? I need to implement both business_hours and let's say, delivery_hours (hours that delivery is available) so that double the number of colums which makes the jsonb column a great option - thanks for outlining that.

I'm going to take a stab and then I'll try to share a gist if I can get it to work for others.

Posted in How do I manage business hours for a store?

I've taken a few stabs at this over the past two months and haven't found a great solution for what seems to be a straightforward feature seen in applications such as SkipTheDishes and UberEats.

Given a Store model, what are the associations needed to manage their business hours and how is that form rendered? Ideally, when a user creates a Store, they should be prompted to add their business hours. Maybe default hours are generated via callback?

Looking for some insight if anyone has experience with this.

Posted in User Onboarding Progress Bar Discussion

Finally went through this in Rails 6, thanks again...didn't think it would be so cut and dried. Now that same HTML div tag can be generated as follows:

tag.div class: ["fa-check", color]

<div class="fa-check text-success">

Posted in Improving In-App Notifications Discussion

Just the answer I was looking for!

I didn't realize I could access conversation.recipient and conversation.sender so easily, going to try to model it as you suggested above Casey :thumbs_up:

I haven't written the portion to parse the email and create the post, but I planned to model it around the logic here, Handling Inbound Email Parsing with Rails

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.