Chris Oliver

Joined

242,860 Experience
17 Lessons Completed
266 Questions Solved

Activity

Posted in New Project Rails 6 rc1 or 5.2.3?

Rails 6 should be just around the corner once they fix a couple of bugs/regressions. Since you probably won't be finished with your app by then, you won't have to worry about the upgrade if you start it in Rails 6 rc1 and you get to take advantage of the new features in Rails 6 if you want.

I've been using Rails 6 for a few projects for a couple months now and it's been very solid.

Posted in Setup Errors for Rails on MacOS 10.14 Mojave

Oops, sorry I wasn't clear. That line of code goes in the Gemfile file, not in the terminal.

Posted in Setup Errors for Rails on MacOS 10.14 Mojave

Hey Jerrica,

Looks like maybe you're just missing this line in your Gemfile:

gem 'bootsnap', require: false

Try adding that and running bundle afterwards to install it.

It's basically just trying to load bootsnap but it can't find it. Bootsnap is a tool to make loading Rails faster. https://github.com/Shopify/bootsnap#how-does-this-work

Posted in How to use Action Mailbox in Rails 6 Discussion

You can definitely do it, but you wouldn't be able to use ActionMailbox for that. You'd want to use something like Twilio and setup a controller to receive the webhooks they send. I've been planning on doing some Twilio stuff, so I'll have to do that soon!

Did you yarn install?

You can run bin/webpack to run webpack and see what the compilation error was.

Posted in To use Rails 6 or Not

I would definitely use Rails 6. It's quite stable and since it mostly is adding some new features, you don't have much to worry about. Also all the gems I typically use are compatible with it so I haven't had much issue.

ActionText uses attachable_sgid from the Attachable concern. That's covered in the @mentions in ActionText video on how that works.

I don't know how you differentiate between the two, but this works for rails app:template

after_bundle do
  p "hello"
end

run_bundle
run_after_bundle_callbacks

There's probably some way to check if it's a new app and only run the last two lines if needed. Maybe by looking up the current generator name or something. I'm not sure.

A quick test applying an empty template to an existing app looks like it doesn't trigger bundle install for these. Just new apps. That may be a difference between the two that isn't documented.

The code I did find was here: https://github.com/rails/rails/blob/470e6bdac97249ca3406c635f611aa8f7df8b222/railties/lib/rails/generators/rails/app/app_generator.rb

There's a run_bundle mention in there which leads me to this:
https://github.com/rails/rails/blob/2e4c65e3afb18fc9a84d4d3ae893209efce27592/railties/lib/rails/generators/app_base.rb#L407

You can probably add run_bundle to your template to make sure it runs it. I would assume this would also trigger after_bundle code as well.

Unfortunately, ActiveStorage isn't currently flexible enough on the processing side of things.

You'll be better off using Shrine if you want to do any transcoding right now (unless you pay a service to do transcoding for you). I've used streamio-ffmpeg with Shrine to convert videos before.

https://gorails.com/episodes/shrine-background-and-video-transcoding

Posted in Bidding App

Hey Ryan,

I would probably create like a Bid model that kept track of these. Since you don't want to charge until the very end of the auction, you'll want to keep track of the bid history and then charge the winner (or runner up in case something falls through, etc).

Then you'd just add validations to check against previous bids for the product and make sure they're $25 more than the last.

Posted in Rails & Vue.js Trello Clone - Part 4 Discussion

Have any information on that? It looks like the Draggable docs (https://github.com/SortableJS/Sortable#event-object-demo, search for "onEnd") show the following object.

    // Element dragging ended
    onEnd: function (/**Event*/evt) {
        var itemEl = evt.item;  // dragged HTMLElement
        evt.to;    // target list
        evt.from;  // previous list
        evt.oldIndex;  // element's old index within old parent
        evt.newIndex;  // element's new index within new parent
        evt.oldDraggableIndex; // element's old index within old parent, only counting draggable elements
        evt.newDraggableIndex; // element's new index within new parent, only counting draggable elements
        evt.clone // the clone element
        evt.pullMode;  // when item is in another sortable: `"clone"` if cloning, `true` if moving
    },

It's been a while since I did this, so if this changed, then it may need a couple tweaks to match up, but at least here you have information on all the properties from the event.

The recommended place for stylesheets in Rails 6 is still the asset pipeline. Tailwind is a css framework generated by JS so it needs to be more tied to things than Bootstrap.

This is all just side effects of whats going on in modern frontend. Rails is just trying to make that easier, unfortunately it is pretty messy I think, but its also doing more complex things now.

Yup, exactly that. Match haml files instead of erb.

Posted in How add PurgeCss with TailwindCss?

Hey Nikola,

I just posted an episode on this yesterday: https://gorails.com/episodes/purgecss

Posted in Active Query: object date within the next 30 days.

Yeah! Aren't they handy? It just makes your code so much more readable later on.

Also, another small pro-tip is you can do a scope with an argument like so:

scope :in_next_days, ->(amount) { where("cutdate BETWEEN ? AND ?", Date.current, amount.days.from_now) }

This would let you call Node.in_next_days(30) and pass in the length of time if you wanted the next 7 days or something different.

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.