Chris Oliver

Joined

291,480 Experience
86 Lessons Completed
296 Questions Solved

Activity

When you <%= render comment.comments, it isn't specifying any order, so you'd want to sort that by created_at if you want them in a particular order. A SQL query doesn't respect any ordering unless you tell it to.

<%= render comment.comments.order(created_at: :asc)

Posted in How long does it take for comments to post?

The episode comments are also forum threads, so let me know if you still have issues. I need to go through the forum code some more and polish it up again. It got overrun a bit by spammers before so I've been trying to get it back in order.

Posted in How long does it take for comments to post?

Actually, I don't see your other comment. Hmmm! That's weird.

Posted in How long does it take for comments to post?

It probably got marked as spam. I'll check the comments and unmark it for ya.

Posted in Video request: using message_bus gem

I've had this on my todo list for a while now and just haven't had the time to explore it properly so I can make a screencast. I'll have to do this soon.

What's the reason it doesn't work with Capistrano 3? Rails 5.2.1.1 has an important security fix that you'll want to get running in production as soon as possible so your server doesn't get hacked.

Posted in Suggestion for a new episode

Great idea! And yes, I would do a cron job. It'd query for maybe like the top 10 posts of the week, or whatever content you want to display. Then just pass that into a mailer and send those out.

You might want to revert your foundation-rails gem back to the previous version, or see what's changed because it looks like the foundation/functions asset no longer exists like it used to. They may have just moved it or renamed it.

Posted in Inviting Users with devise_invitable Discussion

I would use the database values. It's not going to slow you down to do that, since you'll already have the database records in memory to display them on the page. You can then do whatever you find easiest to change the buttons.

I would probably just use an if statement to check the different statuses of a user's invitation and then display different buttons accordingly.

Posted in Go Rails' Stripe lesson and strong params

Hey Mark,

It's a great question! Here we were skipping strong params. In either case, it'll accept any input the browser sends over. We're explicitly setting columns in this case which is safe.

The problem that strong_params prevents is attackers who add in extra fields into the HTML and submit something like user[admin]=true that you weren't expecting. Strong params makes a whitelist of attributes it will accept, so if you passed in admin, it will ignore it or throw an error.

Since we're explicitly setting a param to a column, it has the same effect. Rails added strong params so you didn't have to manually write all that out every time.

Posted in How is the Front End of GoRails Built?

Awesome right? It's super fast. Just make sure your Rails requests are fast too. I cache a lot and have it stored in redis (or memcached). That way Rails has even less work to do and can serve up things faster.

Posted in How is the Front End of GoRails Built?

It's just Turbolinks as usual. 🤠

I've never used Salesforce, so that makes it pretty hard to teach. I'll have to look into it sometime. Any pointers where I would start to check it out and what I could do as an example?

One important note to make:

Rails 6 will be using Webpacker by default for Javascript, so it will probably be getting rid of coffeescript as well. You might want to just make the upgrade now if you can so you'll have an easier time upgrading to Rails 6.


Your error is saying the variable you called ".onclick" on was null. The variable was the result of your getElementById, so it's saying it can't find that element on the page. I'd check that out.

Your Coffeescript looks fine, so I'd double check your HTML and make sure it has something with id="p" in it.

You're right. Ideally you want the same version in both places that way what you run in development you know will work in production.

Let me know how it goes. You're pretty close. The first few times are always a huge pain with Capistrano.

Agreed, I can definitely see the confusion.

The whenever line is only needed if you're using whenever.

The second is just an example error message of what happens when you haven't created the database.yml file on your server yet. You should see a similar error.

Posted in Inviting Users with devise_invitable Discussion

Yeah, basically private projects need a ProjectUser association to keep track of who has access. A public one can ignore that since it's open to everyone.

If you're already using CanCan, keep using it. Pundit's just an alternative.

Devise invitable does have a method for doing that, it's in the docs somewhere. 👍

And glad I can be of help!

Interesting to see "LoadError: cannot load such file -- capistrano/rails"

Do you have the capistrano-rails gem in your Gemfile?

I currently have this:

group :development do
  gem 'capistrano', '~> 3.11.0'
  gem 'capistrano-passenger', '~> 0.2.0'
  gem 'capistrano-rails', '~> 1.2'
  gem 'capistrano-rbenv', '~> 2.1'
end

And my Capfile looks like:

# Load DSL and set up stages
require "capistrano/setup"

# Include default deployment tasks
require "capistrano/deploy"

# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#   https://github.com/capistrano/passenger
#
# require "capistrano/rvm"
# require "capistrano/rbenv"
# require "capistrano/chruby"
# require "capistrano/bundler"
# require "capistrano/rails/assets"
# require "capistrano/rails/migrations"
# require "capistrano/passenger"

require 'capistrano/rails'
require 'capistrano/passenger'
require 'capistrano/rbenv'
require 'whenever/capistrano'

set :rbenv_type, :user
set :rbenv_ruby, '2.5.3'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }