Activity
Posted in Rails Counter Caches Discussion
Here's the latest episode on advanced counter caching. 🙌 https://gorails.com/episode...
Depends on what you're trying to accomplish (like everything right? lol). What kind of search are you trying to pull off?
Yeah that's correct, if you're doing both you'll want to make sure any forms submitted verify authenticity token and the JWT token is the only one that should skip that. 👍
Posted in Decorators From Scratch Discussion
That's a great question. If you need to build decorators that work in both cases, then yes, you'd want to do one of two things:
1. Separate decorators for JSON and HTML and wrap them accordingly depending on the response type. Downside to this is more decorators.
2. Build generic decorators and leave it up to your views. Downside to this is that part of the benefit of having the link_to's and etc in the decorator is that your view can remove logic entirely. That's probably not possible if you're not able to write logic in the decorator.
Posted in Get Paperclip file before save
That's a fun one. I would imagine you could build a validation for this that would do what you want.
Some pseudo code for you:
class Model
has_attached_file :attachment
validates :attachment_against_api
def attachment_against_api
response = API.send(attachment)
errors.add(:attachment, response.message) if response.failure
end
end
Posted in Decorators From Scratch Discussion
I thought that was the case! It didn't work for me the first time I tried it, but it could have been spring caching things or something. Thanks for sharing that. :D
Posted in Caching static pages without CSRF token
CSRF tokens are generated for each user, which is why they should not be cached. The CSRF tokens are specific to each user and request so that you can determine whether or not it was the user taking this action or malicious code.
To solve this you have 3 options:
- Don't cache the form
- If you're fragment caching, use Javascript to include the CSRF token. See here: https://coderwall.com/p/0sctaa/forms-csrf-authenticity-token-and-fragment-caching-in-rails
- If you're doing full-page caching, use one of these mthods: https://www.fastly.com/blog/caching-uncacheable-csrf-security
Posted in Mention
Hey Aime,
I don't believe there was much (or any?) CSS in that episode that I wrote. All the source code for that episode should be here: https://github.com/gorails-screencasts/gorails-episode-78
Atwho.js does include some CSS with the library to style the mention box: https://github.com/ichord/At.js/blob/master/src/jquery.atwho.css
Posted in Keeping track with Annotate Discussion
Yep, shouldn't have a problem. You can always check out their GitHub if you run into issues.
Posted in Keeping track with Annotate Discussion
Rake isn't deprecated, they just added a way for you to call it with the rails command so it's less confusing when to use rake vs rails commands. It still functions exactly the same, just simpler now. 🙌
Posted in Rails Counter Caches Discussion
I mean to reply last week but lost the browser tab. :)
Absolutely love these suggestions and I'm going to record a video on advanced counter caches for sure. Please keep the suggestions coming, these are all fantastic and a welcome addition to all the beginner screencasts I often get requests for.
Lots of options. Depending on how long it takes you might want to do this every 4 hours or something instead. You might want to do a live replica database for realtime backups to another server and then archive a copy of it nightly.
Posted in The Params Hash | GoRails
You're welcome! Let me know if you have any suggestions on other topics like this you'd like to hear explained. it's easy for me to take these things for granted these days so ideas for topics are always welcome!
Make sure you're not requiring the active admin css file in your application.css on accident (probably with a require_tree). Their CSS is made to be compiled separately into another file out of the box and so you don't want to include their CSS with yours. That's probably happening with a bad require or import in your application.css at the top.
Posted in Decorators From Scratch Discussion
That's pretty neat. I know I've seen SimpleDelegator mentioned before in but never looked into it. I'll have to fiddle with it now!🤘
Posted in Decorators From Scratch Discussion
That's awesome to hear. Thanks Nick! :)
Hehe 😎 I actually saw that earlier when I was poking around the offline web app stuff on MDN when we were talking about ServiceWorkers. I haven't done a whole lot with stuff though, just dabbled.
Unfortunately AppCache was deprecated in favor of Service Workers due to some poor design they discovered on more complex apps. https://developer.mozilla.o... has the deprecation warnings at the top there.
Cross posting this from Slack:
I think your setup looks alright. Any books where the bought_by
is nil means it’s not been sold. When you do checkout you can charge the user and then assign the ID there and it can go off the market.
If someone else was in the process of buying the book at the same time, you can wrap that in a transaction so that when the assign of the ID fails, you can refund the purchase or vice versa. Assign the id first and attempt payment, then undo the ID if the payment fails. Probably that second way would make the most sense (checkout the transactions video I did recently for more on those rollbacks) not having inventory means you get a LOT of simplicity which you wouldn’t otherwise.
Another thing here is that you don’t need an “Order” model or a cart or anything because you can use the book itself for all that information. So you buy it, and the seller ships it and wants to add tracking, you can then just put it on the book if you wanted or associate a shipping record to that book.
Yeah Turbolinks is not designed for mobile apps that need to work offline. It has basic fallbacks but it's intention is never to make fully offline mobile apps.