William Kennedy


12,510 Experience
94 Lessons Completed
4 Questions Solved


Posted in F.submit not creating object

Hey Samantha,

Can we see the rest of your form?

You may have a nested form (as in a form within a form) or your f.submit is outside of the actual form_for block

Hey George,

Yes. Jumpstart pro comes with an API setup that makes it easy to get started with someting like a React Native frontend. I'm actually building a React Native app for my app as well.

You do have to setup things like tailwind for a new React App and architect the react native app yourself but getting setup was no problem for me.


Posted in Multiuser Live Video Chat in Rails Discussion

The last part reminded me of the Brady Bunch. https://youtu.be/B7P6vEgMr4g?t=1027

Cool video(s)

Nice video Chris.

I did something similar on a project a while ago but not with the elegant stimulus js solution.

Something that I am wondering about Websockets. In terms of edges cases or pitfalls that one could fall into pretty easily, what are some good ones to look out for?

Posted in Issue deploying Rails app with capistrano

There are a few possible things going on here. Is your rails master key saved as an env varaiable?


This is why the nil class error could be happening.

If you don't have the master key set then the following line won't work:


Try seeing if the master key ENV variable is set and just come back with any questions.

Posted in embed youtube in actiontext?

Hi ya na,

He did a whole talk about this.


You can embed iframes into ActionText but you have to whitelist the iframe element.


config.to_prepare do
  ActionText::ContentHelper.allowed_tags << "iframe"

Posted in How to Test Validations in Rails Discussion

For validations, I sometimes like to use the shoulda-matchers gem

It's pretty cool because alot of use cases are set up already so it saves having to come up with the edge cases.

For example, in a model test (assuming Rails default not RSpec)
should validate_presence_of(:attribute)

For Rspec, you would write

it { should validate_presence_of(:attrinute) }

Obviously, it doesn't apply in some cases such as custom validate method but it's always a good start into a large codebase that might not have a massive test coverage.

I'm haven't watched the video and never used PurgeCss but I assume you would need to add matcher for .haml files.

/ postcss.config.js

let environment = {
  plugins: [
      autoprefixer: {
        flexbox: 'no-2009'
      stage: 3

// Only run PurgeCSS in production (you can also add staging here)
if (process.env.RAILS_ENV === "production") {
      content: [

            // Matcher for haml

      defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []

module.exports = environment

Posted in Stripe payments course getting out of date

Brilliant. I just happen to working on a project that needs to integrate payments. Looking forward to this.

For people that are asking about embedded signing,  I actually did this recently on a project. Basically, Docusign have an endpoint which returns the url for embedded signing. With the url, you simply redirect the customer off site to sign and then docusign will redirect them back to your app with a status. 

Create JSON like so 

signing_url_json = {
    userName: "something"
    email: email,
    recipientId: "1",
    clientUserId: 1,
    authenticationMethod: "email",
    returnUrl: url

Then post that JSON to the endpoint

"/envelopes/#{envelopeId}/views/recipient", signing_url_json.to_json

I can go into much more detail if people want me to. 

Posted in How do I transfer user data on delete

That's a good idea. Having a step-by-step process for deletion. Then you can just capture the new user who going to get everything transferred to. Best of luck. Hope I was able to help a little

Posted in How do I transfer user data on delete

Interesting. I think you could use callback for delete

class User < ActiveRecord::Base
  before_destroy :assign_courses


  def assign_courses
    new_user = User.new_user_responible #some way of finding the next user responsible
    courses.update_all(user: new_user)

Then you would just create a method for each table you want to transfer. 


You will also need to implement some scope on your User model to find the employee who is going to be assigned all the notes. 

Posted in How do I transfer user data on delete

You may have to divide and conquer the steps first. 

1. Identify the users you want to delete
2. Identify the employee
3. Transfer id
4. then delete user

depending on the table, you could use SQL to a large update provided you're able to find the users

UPDATE employees
    ON "{your condition}"
SET  employee.foreign_key = user.foreign_key
WHERE {condition}

I know it's not an exact answer but might point you in the right diraction

Posted in Can anyone suggest me best Ruby on Rails 5 book?

Rails Tutorial by Hartl is one that springs to mind. I also recommend Agile Development with Rails by Sam Ruby and Dave Thomas and DHH. After you build a few things, you will quickly get the hang of it

Posted in How do I generate dynamic classes?

Ya I was looking at that but then I found this cool library that accomplished what I wanted. 


I'm play around with it some more and see if I can come up with a robust solution. 

Posted in How do I generate dynamic classes?

Is there a way to generate dynamic classes with scss/sass? For example, in my HTML. I want to write 

div class='mt-10'></div>
div class='mt-7'></div>
div class='mt-3'></div>

This should create a div that has a margin-top of 10px, 7px, 3px and I imagine the CSS will look like this:

.mt-{x} {
  margin-top: x;

Any help appreciated?

Posted in Writing Tests for Rack Middleware Discussion

Great video Chris. 

Posted in Open Closed Principle Discussion

Quick question Chris, when you were building out functionality like this for Hatch, how much of this structure do you plan versus how much did you arrive at through refactoring and iteration? 
Hi Arjun,

You could use normal JS with the setInterval method. Something like this: 

function timer(seconds){
    const then = Date.now() + seconds * 1000;
    countdown = setInterval(() => {
        const secondsLeft = Math.round((then - Date.now()) / 1000);
        if(secondsLeft < 0) {
    }, 1000)

function displayTimeLeft(){
 //update dom

I did something like this as part of a Javascript 30 course by Wes Bos. Recommend checking it out


Here is how I achieved the same effect using bootstrap 3. There is a div for each icon essentially. For font-awesome, you would just need to use the i class in the div. Hope that helps. 

<div class="input-group">
<div class="input-group-addon">€</div>
<%= f.text_field :field, class: 'form-control' %>
<div class="input-group-addon">.00</div>
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.