This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| # E.g.: | |
| # limit :create, to: 10, within: 3.minutes, go: -> { new_session_url } | |
| module RateLimitable | |
| extend ActiveSupport::Concern | |
| included do | |
| add_flash_types :rate_limited |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Views::Mailers::Users::Welcome | |
| include Mailable | |
| def initialize(user:) | |
| @user = user | |
| end | |
| class Html < Phlex::HTML | |
| def view_template | |
| p { "Welcome, #{@user.name}!" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| bundle init | |
| bundle add rails --quiet | |
| echo 'Done.' | |
| railsnew='bundle exec rails new . --database=postgresql -f' | |
| gum confirm "Proceed with \`$railsnew\`?" \ | |
| --default=false \ | |
| --show-output \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sure, here are some ideas that will hopefully expand on my post: | |
| 1. validation: in Django, the responsibility of validating model data | |
| is shared between forms and models. Plus, validation logic is not | |
| triggered by default on `Model.save()`, you need to explicitly invoke | |
| `Model.full_clean()` before saving, otherwise you may incur in errors | |
| from the database itself. I think this is not a good pattern to go with. | |
| This works great as long as the only source of incoming data is forms, | |
| but in modern web apps data can come in from a very broad variety of | |
| sources, which makes this approach unpractical. |