Sebastien Auriault
Developer
Posts
💎Rails tip: Exists?
Do you sometimes simply need to know if a record exists and not get its data? ActiveRecord gives you this convenient method "exists?" to do exactly that, in a performant way.
💎Ruby tip: Debugging exit all
Debugging with IRB/Pry and stuck in a loop or just don't wanna go through all the stops typing exit all the time? No need to shut down your server! Simply type 'abort'. This will exit out of all future stops.
💎Rails tip: Rails Runner
Did you know that you can use Rails runner command to run Ruby code from the terminal directly in the context of your application without having to go in the Rails console?
💎Rails tip: Rails console sandbox
Need to test some code that runs queries? The Rails console sandbox is the perfect place to play around without affecting your development data.
💎Rails tip: Console custom methods
Did you know you can add custom methods automatically available in the Rails console? Useful for things you often need to do in the console like logging in.
💎Rails tip: Debugging views
Did you know that since Rails 6.1, you can add one line in your config to have comments added to your HTML showing you where each part of your view comes from (layout, component, partial..)? Useful for debugging views in the browser.
💎Rails tip: Form namespaces
Did you know you can add a namespace to your forms so that you don't need to manually specify the URL when the model doesn't match the controller's namespace? Useful when your app can use the same resource in different places.