Chris Oliver

Joined

291,530 Experience
86 Lessons Completed
296 Questions Solved

Activity

Hmm, you might want to consider doing AJAX submits of those forms so that they don't have to step on each others toes like that. This would also solve your very minor URL issue where submitting a form takes you back to the same page with a very differnet URL.

Have you considered submitting the forms with AJAX?

Posted in Email Stripe Receipts

Hey Steve!

Stripe has their own receipts that you can enable but they're very basic. You'll probably want to turn those off and send your own emails here.

Your code for this is exactly right. You'll want to pass in the charge / user information into the Mailer so that it has access to that to print it all out, but that's the only other thing you should really need to setup. I also added the PDF as an attachment to the email receipts for GoRails as well which has been nice. Might also consider doing that if you've got PDF receipts.

Posted in Access Rails constants from Webpack-managed JS

I haven't used the erb loader yet, but you might also consider just storing the json for the wizard pages in the DOM somewhere (probably in a head tag) that Webpack stuff loads. That's what I was showing in the VueJS examples of loading the data attribute for editing records, but since your JSON is more constant it would make more sense to put in the head instead of inside the body.

Hey Adrian,

What do you mean that it prevents comments from being created? Are you getting an error?

One thing I noticed is you're doing update attributes before you save, so it will try to save to the database twice there. The update_attributes call will hit the database. I believe you'd actually want:

@comment = Comment.new(comment_params)
@comment.assign_attributes(task_id: @task_id, user_id: current_user.id)
@comment.save!

That could also be written a few different ways, for example simply merging iin the task_id and user_id into params and making it a one-liner instead.

One other recommendation, when you're creating the other events / notifications you might consider doing this in an ActiveRecord transaction so you can get a bulk insert into the database which should be quicker than one-by-one.

Posted in 3rd party integrations using Oauth/omniauth

So for anyone logged in already, you can just link them to the authorization path. That will do the redirect and send you back to the Omniauth controller and because you know your user is signed in, you can attach Salesforce to the user instead of creating a new user and attaching it to the new user. It's almost exactly the same process except for that change when the user is already logged in.

You know, I just realized that you're attempting to load npm packages in Webpack but then access them from the asset pipeline. This is why you're having issues with it.

These are totally separate pipelines. You can actually write your own stylesheets entirely in Webpack and include them without using the asset pipeline. There's a separate tag for accessing stylesheets in Webpack <%= stylesheet_pack_tag 'hello_react' %> that never touches the asset pipeline.

You'll have a lot better time if you include your assets this way if you want them to load node packages like that.

Posted in Watchlist Toggle

Ah yeah, I forgot to mention that (and it looks like I forgot to reply earlier too!).

I do plan on adding filters for these things in the Episodes list at some point in the near future. 🙌

That's a fantastic idea Nick. I actually just dove kind of right into the deep end myself and it would be great to take a step back and show what it is and why you might want to use it. I'll definitely make a screencast on this!

Yeah I was gonna say, no sense in fiddling with this if what you got works. :P

I'll have to check out loading CSS with webpack sometime soon and see how that all works. This stuff is an absolute mess. I hope that it gets more sane in the next few months.

Yeah, I figured it wouldn't work automatically like that. I'm not used to using webpack with SCSS, so it's new to me.

From a random Github issue, it looks like maybe adding a tilde at the beginning would work? @import "~bulma/bulma/utilities/utilities";

You can actually use yarn now to add packages which is a little better than using npm now. yarn add bulma will do the same thing as above and it makes things easier.

One thing I will say is I think that you shouldn't have to specify the node_modules folder at all. That should be available in the path I would assume. You should be able to do something like this instead: @import "bulma/sass/utilities/initial-variables"

Yeah, I was going to suggest the geocoder gem. It's probably the only one I've used over the last few years and it works rather well. Documentation isn't super duper great, but it's not bad.

Let me know if you have any questions on it!

Yeah, some interesting changes in how forms work by default. I was disappointed to see that scaffolds don't submit forms with AJAX as that seems like one of the obvious places for them to change and show you how to submit and handle errors.

I'm planning on doing a deeper dive into Rails UJS to see all the new features soon. Seems like a lot has changed instead of it just being a direct port to remove jQuery like I thought it was supposed to.

You can actually use rails form tags and put your vue element inside it and on submit, look up to the form for the url, the method, and csrf token.

The reason I didn't do that here is because the new Rails UJS library was throwing some JS errors for me because it was intercepting the button clicks inside the form. I didn't have time to figure that out so I just removed the form and did it manually. Meant to mention that in the video as that's the way I would ideally set it up.

Well you wouldn't because it's up to your Javascript to generate the views dynamically. You would just cache the JSON response server side and the browser will generate the html from scratch every time.

Mostly the reason why AMS is used over jBuilder is that it's agnostic from the format. You can choose to output AMS in different formats using different adapters like the JSON API adapter. This means you can define the attributes and relationships of your data that you want to export, but you don't have to match that exactly with the JSON format. It becomes more interchangeable that way and you can make modifications a bit easier.

jBuilder is a lot more manual building out the exact structure of the JSON which makes it a bit harder to work with generally.

You've just got to download the backup, extract it, and reimport your database and do the same for whatever else you may have backed up.

Interesting, so that would mean that your filter is likely the piece that's not working correctly. You may want to also console.log tree so that you can see what that string is and verify that filter is working. I'd guess there's something up with that.

Hey Aaron,

What exactly is it that isn't working correctly? You said that it logs things in the console correctly, which I assume means that every time you change the first select, you always get it to log the correct options for the second one?

If those are the right options being printed from the second console.log in the change event, then maybe the problem is just the html call to replace the options?

Posted in Code Review: Run Number Refactoring Discussion

I didn't have time to get into that at all. One thing is that if you have a database unique index, then the database won't accept duplicate numbers which is good. You would probably want to add a "retry" in so that you could increment again and try that number maybe a few times.