...the redirect. It is preferrable to use the newer status code to avoid unexpected behavior. 303 See Other The response to the request can be found under another URI using...
...all future requests should be repeated using another URI. 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change. So, for...
t.string :title t.references :user t.timestamps end end end class Task < ApplicationRecord belongs_to :user validates :title, presence: true end class User < ApplicationRecord has_many :tasks accepts_nested...
for (let element of clone.querySelectorAll('[name]')) { element.name = element.name.replace(NESTED_NAME, uid) } template.insertAdjacentElement('beforebegin', anchor) anchor.appendChild(clone) } up.compiler('[nested-records]', function(container) { const template = container.querySelector('[nested-records--template]')
...has attributes like these: class User < ApplicationRecord has_many :posts end class Post < ApplicationRecord belongs_to :user validates :user, presence: true # Default for belongs_to on Rails 5+ end
We recommend configuring Selenium's unhandled prompt behavior to "ignore". When running tests in a real browser, we use Selenium. Each browser is controlled by a specific driver...
...when performing most options, like a simple visit or execute_script from Capybara. Different behaviors While drivers default to dismissing user prompts, you can change that. Specifically, the specification describes...
Rails applications and ruby gems should have a README that gives the reader a quick overview of the project. Its...
...to add additional fields to keep track of all localized versions, e.g. Article#name becomes Article#name_de and Article#name_en and Article#name returns the variant in the...
...at the requests's IP or Accept-Language HTTP header. Note that even the best default never replaces a language switcher. Routes and URLs You might want to localize route...
...named main, add a file app/webpack/packs/main.js. This will be your entry point. All assets belonging to that pack need to be imported here. Since webpack is configured to use Babel...
...its own import statements to load any dependencies it might have. Since this quickly becomes cumbersome, we usually add the following to simply import all our JavaScript files at once...
...are of course much more significant with real / more complex code. What are the benefits of more modular code? Code is written once but read often (by your future self...
...that does net yet exist Sometimes it can be easier to find out the best API of a class by using that code first from the place that will be...
...up-clickable] attribute to make elements interactive. Elements with this attribute gain the following behavior: The element is given an [role=link] attribute so screen readers announce it as link...
...developer stories. Non-developer stories Non-developer stories should be clearly marked. They usually belong to the PM (or maybe people from the operations team). Those story can take all...
In a Jasmine spec you want to spy on a function that is imported by the code under test. This...
tl;dr git checkout is the swiss army of git commands. If you prefer a semantically more meaningful command for...
When you repeat a subpattern with a *, + or {...} operator, you may choose between greedy, lazy and possessive modes. Switching modes...
Don't forget users with a slow internet connection. Not everyone is sitting behind a FTTH cable with warp speed. Throttle your browser's internet connection (e.g. in the...
...Chrome DevTools network panel) to feel how your app behaves. If you're using Unpoly, show a loading state while requests are loading. If you cannot implement this for every...
...instantly. CSS, JavaScript and the browser settings all have options to influence the scroll behavior. They all interact with each other and sometimes use the same words for different behavior...
Scrolling elements can use the scroll-behavior CSS property to express a preference between smooth and instant scrolling. Preferring instant scrolling CSS can prefer instant scrolling behavior: html {
...where_values_hash. This should be the least preferred option. Often times, you are better off using invert_where (if available), Arel or a subquery...
Nowadays it is fairly easy to intercept and modify mails globally before they are sent. All you have to do...
...Most specs don't require you to define a class. Usually, you test the behavior of an existing class from your application. A common use case ist testing modules which...
...are included elsewhere. Your module may behave differently depending on the including class, be parameterized (like with Modularity), or just offer an API (e.g. has_defaults) that you want to...
You have uncommited changes (you can always check by using git status), which you want to discard.
Both knapsack and parallel_tests have the option to split groups by historic execution time. The required logs for this...
When you allow file uploads in your app, a user might upload content that hurts other users. Our primary concern...
This guide shows how to create an AngularJS application that consumes more and more memory until, eventually, the browser process...
...application does not need to support time zones. Disable them like this: config.time_zone = 'Berlin' # Your local time zone config.active_record.default_timezone = :local config.active_record.time_zone_aware_attributes = false
...s Time will use that. In the example above, it should be in the Berlin zone. Using time zones If your application should support time zones, the default ActiveRecord configuration...
Here are some popular mistakes when using nested forms: You are using fields_for instead of form.fields_for.