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...

...Rails docs, e.g. Array#to_sentence String#dasherize Hash#slice Object#presence Libraries The best way to learn about a Ruby gem, Javascript libary, etc. is often to find the...

http://unpoly.com https://lodash.com/ https://fontawesome.com/icons Web Platform (HTML, JavaScript, CSS) The best reference to look up information on HTML tags, JavaScript features or CSS properties is the...

...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...

If you need to pre-generate a scram-sha256 password hash for use with postgres, e.g. for using it with...

Some tasks in a web application are better not done live when a user request a page, but in the background. Examples are longer running tasks tasks that are not...

...been accepted for 7 days. Learn about Sidekiq Read Sidekiq's Readme Read Sidekiq best practices Read Sidekiq Error Handling Understand how to schedule jobs, and work them off

makandra dev

...changes you make to the database will be rolled back on exit. Warning Changes beyond the database (deleting files, sending emails, etc) cannot be rolled back...

...shared_examples_for can have parameters. You can simply hand over arguments from it_behaves_like: shared_examples_for 'string equaling another string' do |expected_string| it 'is equal to...

...subject).to eq(expected_string) end end describe 'some string' do subject { 'foo' } it_behaves_like 'string equaling another string', 'foo' end RSpec 1 Use it_should_act_like from...

Capybara provides execute_script and evaluate_script to execute JavaScript code in a Selenium-controlled browser. This however is not...

When users type into a Tom Select control, the options list is updated with a short delay which can feel...

haml.info

...nesting level of elements. When it comes to white-space preserving content, this may become a problem: the content will be rendered including the HTML indentation. Problematic: Preserved Indentation

%pre = content Reference Hello World Better: Without Extra Indentation Render with tilde ~ instead of equals = to keep Haml from indenting content: .nest %span Reference %pre ~ content Reference

When setting up cronjobs, commands somtimes output something every time. If these commands don't support limiting their output to...

Rails' url_for is useful for generating routes from a Hash, but can lead to an open redirect vulnerability.

developer.mozilla.org

The linked MDN article is quite informative of a neat feature supported by all major browsers: Unicode character class escape...

If the project team consists of at least 2 members, do a daily standup. It should not take much longer...

Cookies without an expiration timestamp are called "session cookies". [1] They should only be kept until the end of the...

This card explains how to generate an entity relationship diagram for your Rails application. We also show how to limit...

...diverge from remote code. These exercises emulate such situations. You are free to apply better naming conventions to the requested commit messages, they are only kept short here to fit...

Learn to store attachments in a way that is accessible by authorized users only Learn to prevent users from...