Stephen Sizer


3,080 Experience
11 Lessons Completed
1 Question Solved


Posted in Action Mailbox Routes

@chris Legend!! Thanks sir!

Posted in Action Mailbox Routes

I'm adding action mailbox to my Rails + React app, the problem I'm having is that the mounted routes are at the very bottom of the routes file so it will not get called due to the fact that I need a catch all for my react app.

Is there a way to move the mailbox routes to the top of the file?

Posted in User model guidance

Hi All,

I'm creating a coaching app and have two users that use the system a coach and a client. A coach can also be a client of another coach. So I will need to be able to switch accounts to either the client or the coach.

has_many :clients

belongs_to :coach

What would be the best way to do this? Having two Devise models Coach and Client or having two boolean fields on the user to say is_coach, and is_client.

If a coach has an account and then is added as a client, I want that client account to have the same password as the coach account for ease of use.


Posted in Announcements

Hi Chris,

How do you do the announcements in Hatchbox?


Posted in Plan limits

I'm currently building a sass product that has three plans beginner, intermediate and advanced. This is then linked to a stripe subscription product.

Each plan has limits eg. the number of team members they can add, the number of projects they can create.

Whats the best way to handle the plan limits?

Posted in File uploads in Rails with Shrine Discussion

has anyone used Shrine and Backblaze B2 storage?

What is the syntax for querying a boolean value?

Trying the below doesn't seem to work? and throws the following error:

PG::UndefinedFunction: ERROR: operator does not exist: text = boolean

current_user.companies.where("holiday_request_settings ->> :key = :value", key: "enable_holiday_requests", value: true)

If I try the following I get no results:

current_user.companies.where("holiday_request_settings ->> :key = :value", key: "enable_holiday_requests", value: "true")

The company current has the following data:

holiday_request_settings: {"enable_holiday_requests"=>true, "holiday_allowance_days"=>20}

This is the code on the model:

typed_store :holiday_request_settings, coder: JSON do |s|
        s.boolean :enable_holiday_requests, default: false
        s.integer :holiday_allowance_days

Any ideas?

Posted in How do I work out time slots greater than 5 hours

Thanks Chris

Posted in How do I work out time slots greater than 5 hours

I have a booking application where you can book time against a room. I need a way to find where it is booked for more than 5 hours consecutively to do some reporting.

This can be anytime over a 24 hour period.

So for example it might be booked

8:00am - 10:00am (2 hours)
10:00am - 13:30pm (3.5 hours)

This should be classed as over 5 hours consecutively.

There could be an occasion where it would be booked like this:

10:00pm - 12:00am (2 hours)
12:00am - 4:00am (4 hours)

Again this is over 5 hours consecutively

My Models are the following (simplified):


  • has_many timeslots


  • start_time (:date_time)
  • end_time (:datetime)

I am currently looping through each day of the week and looping through each time slot for that day and then checking to see if start_time == end_time of the next slot to work out if it is consecutive. Not sure if this is the easiest way or if there is something more obvious that would do what I need.

Your help is really appreciated.

Posted in Devise Masquerade with multiple Devise User Models

Hi All,

Has anyone used devise masquerade before with multiple devise models. I have and Admin model and a User model.

I'm having issues and when I try implementing it, I can't seem to login as another user.

Thanks in advance.

Posted in Deliver Later not working

Hi Guys,

I have a rails app, and for some reason when I call deliver_later the emails aren't sending. When I test it with deliver_now it works fine.

I have redis and sidekiq both running.
TID-owqrlmxrh ActionMailer::DeliveryJob JID-10b51cc7e7b76d99307add2c INFO: start

the above shows it goes to the queue but never sends. Any help would be much appreciated before I pull my hair out.

I have written two system tests for my current application and I have now hit a road block.

test "visiting the timesheet index without signing in" do
    visit timesheets_path

    assert_text "You need to sign in or sign up before continuing."

  test "visiting the timesheet index (signing in first)" do
    visit new_user_session_path

    fill_in "Email address", with: "[email protected]"
    fill_in "Password", with: "password"

    click_on "Log in"

        assert_text "Signed in successfully."

The second test is failing due to not being able to load a font shown below:

ActionController::RoutingError: No route matches [GET] "/fonts/fa-solid-900.woff2"

If I spin up my rails server locally I have no errors for missing resources and my font files are all loaded correctly.

For further reference I am using the defaults for my application system test case

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium, using: :chrome, screen_size: [1400, 1400]

Does anyone have any suggestions?

Posted in Rails Webpack caching

Found the issue! It was due to my environment file in webpacker causing the assets to not be recompiled.

Posted in Rails Webpack caching

I'm having an issue in development where I've changed my main application.js file in /javascript/packs/ and the file is being cached so having a hard time testing new changes. Does anyone else have this issue?


Posted in How to add an image to prawn pdf?

I'm wondering how to add an image to a prawn pdf from active storage. I've tried a number of ways and can't seem to get it to render.

Thanks in advance,

Posted in Regex getting hashtags

I'm wanting to capture all hastags from the richtext field. I thought I had a solution until I came across testing where the richtext editor put HTML entites into the markup.

<p>#ruby you&#39;re amazing</p>

so at the moment its getting #ruby, #39 any help would be appreciated.


Posted in Attaching file to email Active Storage

Changed to _url and not get this error:

Unsupported argument type: ActiveStorage::Attached::One
Extracted source (around line #35):

def send_notifications
-- AssignmentMailer.notify_team(user, upload).deliver_later ---

Posted in Attaching file to email Active Storage

Hi Guys,

I am trying to attach a pdf to an email via active storage. Here is my code below and the error I am getting.

class Assignment < ApplicationRecord
has_one_attached :upload
belongs_to :user
belongs_to :course
belongs_to :lesson

after_save :send_notifications

def send_notifications
AssignmentMailer.notify_team(user, upload).deliver_later

No such file or directory @ rb_sysopen - /rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889c8cda6fbfb3c827ff5bcd7a4ca7ff1594a37e/weekend.pdf


Posted in Searchkick Elasticsearch filtering

Does anyone know of any good tutorials showing how to add filters for searching?

Thanks in advance.

Posted in How do I query a model with a value less than

I have a Lesson model that has an order field of type integer. What i want to do is find the previous lesson.

Lesson.where("order < ?" , 8)

This causes the following error. Any help would be appreciated.

Lesson Load (1.9ms) SELECT "lessons".* FROM "lessons" WHERE (order < 8) LIMIT $1 [["LIMIT", 11]]
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "order"
LINE 1: SELECT "lessons".* FROM "lessons" WHERE (order < 8) LIMIT...
: SELECT "lessons".* FROM "lessons" WHERE (order < 8) LIMIT $1

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.