14 Matching Annotations
- Jul 2022
-
stackoverflow.com stackoverflow.com
-
A more conservative workaround is find the gems that are causing issues and list them on the top of your Gemfile.
good solution ... except that it didn't help/work
-
-
discuss.rubyonrails.org discuss.rubyonrails.org
-
Overriding the ActiveStorage controllers to add authentication or customize behavior is a bit tedious because it requires either: using custom routes, which means losing the nice url helpers provided by active storage copy pasting the routes in the application routes.rb, which is not very DRY.
-
- Jan 2022
-
-
Boilerplate is only boilerplate if it's the same everywhere, which it shouldn't be.
-
- Apr 2021
-
stackoverflow.com stackoverflow.com
-
class AuthConstraint def initialize(&block) @block = block || ->(_) { true } end def matches?(req) user = current_user(req) user.present? && @block.call(user) end def current_user(req) User.find_by_id(session[:user_id]) end end This is a flexible approach to defining route access based on any desired variable (roles, auth, etc...)
Good solution, and might be needed if you want to base routes on roles, etc. — but this one is even easier if all you need is for it to be conditional based on signed in or not (because devise provides authenticated helper):
-
- Mar 2021
-
askubuntu.com askubuntu.com
-
This is the only answer that does not require manually parsing the .desktop file, so it's the most sane (and safe) approach.
-
-
www.chevtek.io www.chevtek.io
-
Write modules that do one thing well. Write a new module rather than complicate an old one.
.
-
- Feb 2021
-
github.com github.com
-
For this one we'll define a helper method to handle raising the correct errors. We have to do this because calling .run! would raise an ActiveInteraction::InvalidInteractionError instead of an ActiveRecord::RecordNotFound. That means Rails would render a 500 instead of a 404.
True, but why couldn't it handle this for us?
-
-
-
It makes me happy to see people actually think about things and not just accept a shitty API.
Tags
- less than ideal / not optimal
- don't settle for/accept something that's not as good as it can be
- can we do even better?
- describe the ideal hypothetical solution
- "makes me happy when ..."
- actually consider / think about how it _should_ (ideally) be
- intentional/well-considered decisions
- doing something without knowing why/how it works
Annotators
URL
-
-
-
I typically save everything I can first, and then call the side-effects afterwards. If the side-effects fail I can handle them elsewhere and retry when necessary.
-
- Oct 2020
-
medium.com medium.com
-
Examples of this include: requiring base classes or reading from imported variables that have not been initialized yet.
-
as soon as you have a (indirect) circular dependency, you might be interacting with a half loaded module in your code.
-
-
svelte.dev svelte.dev
-
Just like elements can have children... <div> <p>I'm a child of the div</p> </div>...so can components. Before a component can accept children, though, it needs to know where to put them. We do this with the <slot> element.
-
-
humanwhocodes.com humanwhocodes.com
-
Once again, this isn’t good or bad, it’s just the most efficient way to create something that is similar to something else
-
- May 2020
-
ico.org.uk ico.org.ukHome1