Chris Oliver


247,110 Experience
18 Lessons Completed
271 Questions Solved


Posted in How do I remove Devise::Trackable from my app?

Yep, that should be it. You don't have to remove the columns, but you might as well if you don't need the data.

Thanks Monroe! It's been a heck of a lot of work, but these are the reasons that keep me going. 🙏

The Rails community is a special place. So many helpful people here, so I am thankful for all of you in the community who make this possible!

You'd just need to find a video player that will do it for you (that way you don't have to build it yourself).

There are several other options.

If you wanted to build it yourself, you'd first play the ad, then when it is finished, replace the video with your content. All that will probably be in Javascript and you'd need videos for the ads and such to serve up. And you'd want to collect ad metrics for plays and clicks, etc probably.

Hey Edmundo,

Oh yeah, great point. I believe you just set data-controller="tabs" data-tabs-index="1" to have it select the 2nd tab, but that would have to be rendered in the HTML.

We may want to add some other method of doing this too. Possibly looking at the anchor in the url and selecting the target with the matching ID.

Posted in How to use Action Mailbox in Rails 6 Discussion

Same way params is available to all methods in your controller. It's simply a method defined in the parent class.

That initializer works too. I'm just putting everything in the same class for now to keep it organized.

The stylesheet pack tag is used for serving stylesheets in production, or in development if you have it configured that way.

Posted in Should I rewrite my app?

Basecamp rewrites their app every 4 or so years and continues to maintain the old versions for any users who don't wish to upgrade. They explain it similar to buying a car. Porsche's going to completely redesign the 911 every 5 years or so, but that doesn't mean all existing 911 users are forced to upgrade. They can if they'd like to, but there's no requirement to and you only have to fix bugs (which should get less and less over time) on the old product.

I always thought that was an interesting philosophy for software which almost never is seen this way. You're always forced to upgrade to the rewrite. Something to keep in mind!

And if you rewrite, I'd consider using the existing database and then adding any migrations you need to change it to how you'd like it to be. That way you can more easily transition customers over to the new version.

Great points! 👍

Yeah, that should be correct. You'd multiple the two together to get your minimum pool size since each thread would need a database connection to operate (since they're doing the work).

Your app would look like this:

worker 1 
-> thread
-> thread
-> thread
-> thread
-> thread
worker 2
-> thread
-> thread
-> thread
-> thread
-> thread

Posted in Help

Your first if doesn't have an end.

Try writing it like this:

def can_you_vote?(age)
  if age >= 17
        print "True"
      print False

Posted in Nested Comment Threads in Rails - Part 1 Discussion

Hey Arnas,

Just make your form match your routes like you normally would:

<%= form_with model: [@project, @task,], local: true do |form| %>

Posted in Thoughts on Rails 6, is it ready for production?

Yep! I think RC1 is just fine. It's called a release candidate because if there are no bugs or regressions, this is exactly the code that will ship as the final version.

I believe the only bugs in rc1 right now are related to the new features, so as long as you're not using those too heavily, you're good to upgrade.

These are the open tickets preventing Rails 6 from being released:

I know you can use an administrate custom field to customize the form field. There are some gems out there to help make that easier but I can't remember the name of the one that does this.

This one isn't quite right since it seems like it's only for belongs to, but it's almost exactly what you want:

Posted in Introduction to Importing from CSV Discussion

Correct, you need validations for uniqueness so you don't get duplicates. Email is typically the field marked for uniqueness.

Wicked is pretty great. It's about as simple as it gets because if you built it yourself, you'd basically be creating wicked. I don't know of many other options, but it's pretty easy to use.

Posted in ActionCable in JumpStart project

Hey Stefan!

Everything is basically exactly the same, except that your Javascript is now in app/javascript instead.

The easiest way to setup a channel is just to run the rails generate for it:

rails g channel MyChannel

And it will take care of creating the files for you.

You can read about the JS stuff here in the edge guides:

Posted in "You must use Bundler 2 or greater..." Error

Try upgrading to Ruby 2.6.3 (it's the latest version anyways).

There was an issue in Ruby core that they mentioned here in this discussion about the issue.

This Bundler 2 stuff has been an absolute mess.

Posted in rvm vs rbenv

Bundler handles all that for you, so gemsets don't do anything these days. Your Gemfile dictates the versions for each gem, so as long as you have a Gemfile for your apps, you're set. It won't even attempt to load other gem versions.

Gemsets from rvm are from back in the early, early Ruby days when Bundler didn't exist. There was not a good way of keeping track of gem versions, so they introduced that to help. It hasn't been necessary since then.

I personally use rbenv because it's less intrusive. Rvm will override methods in your bash prompt and rbenv does not. There can be conflicts that come up and cause problems, and rvm is a bit harder to set up in production. I've ended up doing some complex things with Ruby (like building Rails hosting with, so having a simpler ruby version manager like rbenv comes in handy for things like that.

You're free to use rvm if you like. You probably don't have too much of a reason to switch, so don't worry much about it.

Posted in Display Posts on Homepage

Hey Mike,

If you want to list posts on the homepage, you just need to query for them in your homepage's controller action.

def index
  @posts = current_user.posts if user_signed_in?

Also if you use Devise, you can actually change the root when a user is logged in which I find to be the most easy option for modifying the homepage when a user is logged in. That way you can point it to any controller action and it'll be separated out nicely.

# config/routes.rb
authenticated :user do
  root to: "posts#index"

root to: "homepage#show"
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

© 2020 GoRails, LLC. All rights reserved.