You can use nmap to find out what service is running behind a given port, and most often see some details about it. This can be helpful if...
When you don't only have a favicon.ico in your project but also PNGs of different sizes and backgrounds, you...
Rails offers the fresh_when method to automatically compute an ETag from the given record, array of records or scope...
The default configuration of Rails disables CSRF protection in tests. If you accidentally forget to send the CSRF token for...
...like keeping some HTML. If you only care about line breaks, you might be better off using a small, specialized helper method: def format_linebreaks(text) safe_text = h(text...
...the CSS property white-space: pre-wrap. With pre-wrap two line breaks will behave like , they do not actually produce elements. You can call simple_format with custom sanitization...
This cards describes an example with a Github Client on how to keep your Rails application more maintainable by extracting...
...you obviously do not want to duplicate it and your tests might very well benefit from this approach. Use it with care, however -- doing this more than a few times...
...making the test impossible to read). An alternative is also to hide that functionality behind other steps that do more complex things differently...
...the HTML required attribute. We usually turn it off due to difficulties controlling its behavior and appearance. Instead we only mark required fields with an asterisk (*) next to its label...
...after submitting the form due to the now displayed error messages. A compromise with better accessibility is to add the aria-required attribute in this case. This allows screen readers...
When HTTP clients make an request they can define which response formats they can process. They do it by adding...
Knowing when to refactor Just feeling like refactoring is not a good reason to do it. Make an educated decision...
simple_format ignores Rails' XSS protection. Even when called with an unsafe string, HTML characters will not be escaped or...
...change the rendered html, some variation of @message.content.body.to_rendered_html_with_layout Changing the behavior of the editor You may want to add some functionality to the editor or remove...
...addEventListener("trix-action-invoke", event => { const { editor } = event.target if (event.actionName === "x-horizontal-rule") { // ... } // Add behavior for the other buttons // ... }) Check the Trix README to check what you can do.
By default subscript ( ) and superscript ( ) tags are styled with vertical-align: sub, respectively vertical-align: super by most browsers.
...fills in the query "foo" Also see An auto-mapper for ARIA labels and BEM classes in Cucumber selectors
In the Gitlab settings the flag Auto-cancel redundant pipelines is enabled by default. This auto-cancels pipelines with jobs...
Spammers have started abusing other application to send their spam. This works like this: The application has some form that...
When you replace parts of the DOM with new HTML, using .innerHTML = newHtml is usually the simplest and fastest option...
...t have control of. Solutions Don't log SQL queries. This is the default behavior of rails but can be changed in the config/environment/production.rb file: config.log_level should not be...
class Post < ActiveRecord::Base has_one :attachment end # attachment.rb class Attachment < ActiveRecord::Base belongs_to :post validates :title, presence: true end Issue When creating a post with an invalid...
...would allow to detect the end of windows size changing process. Capybara provides a better way to manipulate the browser window which you should use instead: page.current_window.resize_to. Good: Capybara...
...as isolated (more unit like) tests, one might want to test some cookie dependent behavior as a request, helper or model spec too. Since the rspec documentation on testing cookies...
...that into a class to DRY up your code and write solid unit tests. Beware that your class will not be able to read the cookies, since they are only...
...It's much easier to detect the current Rails environment instead. You might be better of checking against the name of the current Rails environment. To do this, store the...
Timecop is a great gem to set the current time in tests. However, it is easy to introduce flakyness to...
...the joins, and then authors for the pluck clause. The first corresponds to the belongs_to relationship, and the latter is the name of the db table. You could even...