Înapoi la articole →

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 49
  1. Beautiful Rails confirmation dialogs (with zero JavaScript)

    This is a guest collaboration with Stephen Margheim, creator of High Leverage Rails, a video course on building high-quality Rails applications with the power and simplicity of SQLite, HTML, and CSS.

  2. Hotwire components that refresh themselves

    This is a guest collaboration with Jesper Christiansen, a long-time fan of most things Ruby on Rails.

  3. Event sourcing is a jargon filled mess that is unapproachable to many developers, often using five dollar words like “aggregate root” and “projections” to describe basic concepts.

  4. Writing better Action Mailers: Revisiting a core Rails concept

    Mailers are a feature used in literally every Rails application.

  5. Sorting ActiveRecord results by enum values (in SQL)

    Rails enums are a great way to model things like a status on an ActiveRecord model.

  6. Thinking in Hotwire: Progressive Enhancement

    There are many tutorials about how to get started with Hotwire and how to use the individual pieces.

  7. Galaxy brain CSS tricks with Hotwire and Rails

    In Hotwire applications, you need to lean more on the fundamentals of CSS and HTML.

  8. Adding keyboard shortcuts and hotkeys to StimulusJS

    Keyboard shortcut support for actions is now built-in to Stimulus 3.2!

  9. The most underrated Rails helper: dom_id

    The dom_id helper in Rails is over a decade old, but has proven to be an invaluable concept in Hotwire.

  10. Self-destructing StimulusJS controllers

    Sometimes you need a little sprinkle of JavaScript to make a tiny UX improvement.

  11. Tailwind style CSS transitions with StimulusJS

    If you’ve built UI elements with StimulusJS before, you’ve certainly written code to show or hide an element on the page.

  12. Dynamic user content in Rails with Liquid tags

    When building features that accept user-generated content, you may need to display dynamic content based on what the user specifies.

  13. Accessing Rails environment variables from a StimulusJS Controller

    Environment variables are a great way to configure your Rails apps.

  14. Rails validations: database level check constraints

    One of the most common Rails tips is to back up your ActiveRecord model validations with database level constraints.

  15. Debugging slow Heroku builds

    It’s always best to follow a systematic approach when trying to speed up slow code.

  16. Quickly explore your data with `uniq` and `tally`

    A common question you may want to answer on user-input data is: what values have been entered and how many times is each one used?

  17. Improving your Rails mailers with `email_address_with_name`

    In almost all email programs, you can add a display name before your email address like so: To: Matt Swanson <matt@example.com> It’s a small touch, but it is a more human-readable way of addressing an email.

  18. Building lightweight components with Rails Helpers and Stimulus

    Custom Rails helpers modules are often overlooked, but they can be a great option for building lightweight components and reducing boilerplate in your Stimulus controllers.

  19. Combine `redirect_to` and the `anchor` option

    Often you’ll have an application screen like this: After editing information about an employee, you’ll redirect back to the Company Directory page.

  20. Lazy-loading content with Turbo Frames and skeleton loader

    Hotwire is a new suite of frontend tools from Basecamp for building “reactive Rails” apps while writing a minimal amount of JavaScript.

  21. Building a Rails CI pipeline with GitHub Actions

    GitHub Actions is an automation platform that you run directly from inside a GitHub repository.

  22. Use `to_sql` to see what query ActiveRecord will generate

    If you’re trying to write a tricky ActiveRecord query that includes joins, complex where clauses, or selecting specific values across tables, it can be hard to remember every part of the ActiveRecord DSL.

  23. Prefer returning chainable ActiveRecord objects

    One of the best parts about ActiveRecord is the chainable query interface: Post.includes(:comments) .where(published: true) .where(author: Current.user) .order(:name) To take advantage of this strength and give you flexibility in your code, always…

  24. Rails validations: unique within a certain scope

    It’s a great idea to make your database and application validations match.

  25. Boring breadcrumbs for Rails

    Breadcrumbs are a common UI pattern in most software applications.

  26. Sharing common code between Rails controllers with `Scoped` pattern

    If you follow a strict REST / nested resources approach to building your Rails app, you might get sick of repeating common controller actions.

  27. Run different ActiveRecord validations based on context

    Sometimes want to skip certain validations on your database models.

  28. Find records missing an association with `where.missing`

    You can’t prove a negative, but what about querying a database for a negative?

  29. Testing multiple sessions in the same test with Capybara

    Sometimes a feature in your application will involve a back-and-forth between multiple users.

  30. Pluck single values out of ActiveRecord models or Enumerables

    Rails has a great, expressive term called pluck that allows you to grab a subset of data from a record.

  31. Never mix up greater/less than when comparing dates again

    When it comes to compare dates, for some reason my brain really struggles.

  32. Super readable String operations with `delete_prefix` and `delete_suffix`

    One reason I love writing Ruby is that it’s optimized for programmer happiness.

  33. Setting CSS classes in Markdown with Jekyll / Bridgetown

    Writing blog posts in Markdown is just great.

  34. Use Heroku Dataclips to share query and do ad-hoc data exports

    Heroku Dataclips enable you to create SQL queries for your Heroku Postgres databases and share the results with colleagues, third-party tools, and the public.

  35. Ensure required environment variables are set when booting up Rails

    It’s common to use environment variables to configure external services or other options in a Rails app.

  36. Search and debug gems with `bundle open`

    Ever get frustrated trying to search through code on GitHub?

  37. Automatically cast params with the Rails Attributes API

    A common practice in Rails apps is to extract logic into plain-old Ruby objects (POROs).

  38. Show relevant chunks of text with Rails `excerpt` helper

    The Rails helper excerpt can extract a chunk of text that matches a certain phrase, no matter where in the string it is.

  39. Use Rails `link_to_unless_current` for navigation links

    We’re all familiar with the classic Rails link_to helper.

  40. Use Rails `cycle` to avoid `i % 2 == 0` in your view loops

    Sometimes you need to keep track of how many times you’ve looped when rendering some views, for instance to alternate background colors to create a “striped” table. <!

  41. Use the Rails helper `highlight` when showing search results

    Use the Rails highlight helper to wrap search result matches in <mark> tags.

  42. Magic Responsive Tables with Stimulus and IntersectionObserver

    This is a guest collaboration with Pascal Laliberté, author of Modest JS Works, a short online book for those who want to write modest JavaScript, and then focus on all the other stuff that matters in building an app.

  43. Hacktoberfest Recap: Open source Ruby/Rails work in 2020

    Hacktoberfest is a month long event that encourages developers to contribute to open source – submit four valid pull requests and you win a tshirt.

  44. Building GitHub-style Hovercards with StimulusJS and HTML-over-the-wire

    Somewhere along the way toward our current JavaScript hellscape, programmers decided that HTML was over.

  45. Writing better StimulusJS controllers

    We write a lot of JavaScript at Basecamp, but we don’t use it to create “JavaScript applications” in the contemporary sense.

  46. Feature Flags: The stupid simple way to de-stress production releases

    “So, uh, is it okay to deploy this?”

  47. Spring Cleaning: Tidying up your codebase

    As the weather warms up, I get energized to give my codebase a spring cleaning.

  48. In case you don’t like reading (Feb 2020 - Indy.rb Meetup) In every non-trivial application you’ll have to do something that is just slow.

  49. Managing Rails schema and data migrations without losing your mind

    As time goes by, you’ll need to change the data model for your software.