When a user shares your content, a snippet with title, image, link and description appears in her timeline. By default...

postgresql.org

...twentieth in what ordering? The ordering is unknown, unless you specified ORDER BY. In Rails, if you use Record.first or Record.last, it will default to ordering by id.

...used to match rows without knowing a secret token: Potential Query Manipulation with Common Rails Practises CVE-2013-3211 MySQL madness and Rails

makandra dev

...after_logout idp_sign_out] end Unsafe redirect when trying to log out Since Rails 7 you need to pass allow_other_host: true to redirect_to to allow a...

...a month or a year. Next, start your application server for HTTPS. For a Rails application with Puma: bin/rails server -b 'ssl://0.0.0.0:3000?key=development.key&cert=development.crt'

...many more processes than just your tests while your test suite is running: The Rails server booted by each test process (in a separate process) The Chrome browser started by...

...is good programming practice to Don't Repeat Yourself (or DRY). In Ruby on Rails we keep our code DRY by sharing behavior by using inheritance, modules, traits or partials...

...Best practices for writing code comments Read the following chapters from our book Growing Rails Application in Practice: Dealing with fat models Extracting service objects Discuss with your mentor what...

...Probably the best approach is to just convert emails (and usernames) to lowercase within Rails. Popular authentication libraries (like Clearance and Devise) already do this for you...

makandra dev

...use a light terminal theme Improving Diffs for Ruby, RSpec and Cucumber files See Rails developers: Have better context in Git diffs. This will correctly identify the beginning of a...

thegnar.com

...your view might be too isolated, since view-specs will mock a lot of rails behavior and render the view independent from the controller-logic. Therefore it will be more...

This RailsCast demonstrated a very convenient method to activate VCR for a spec by simply tagging it with :vcr. For RSpec3 the code looks almost the same with a few...

...vcr and webmock gems installed, simply include: # spec/support/vcr.rb VCR.configure do |c| c.cassette_library_dir = Rails.root.join("spec", "vcr") c.hook_into :webmock end RSpec.configure do |c| c.around(:each, :vcr) do |example|

...Ruby projects. These projects use a large number of different versions for Ruby, Rails and many gems. To be able to switch between projects easily, we must control every dependency...

makandra dev
github.com

...ETag for responses that only differ in CSRF tokens or CSP nonces. By default Rails uses Rack::ETag to generate ETag headers by hashing the response body. In theory this...

...would enable caching for multiple requests to the same resource. However, since most Rails application layouts insert randomly rotating CSRF tokens and CSP nonces into the HTML, two requests for...

kernel.org

...mind that you may need to migrate your database as Git is unaware of Rails and will not cast any magic. If Git checked out a commit that is working...

...The following setup allows you to start Terminator in a split view with the Rails server running in the left pane and all remaining processes running via foreman in the...

type = Terminal parent = child1 profile = default command = env startup_cmd="bundle exec rails server" startup_attrs="-p 3000" bash [[[terminal3]]] type = Terminal parent = child1 profile = default command = 'env startup...

...our older projects, we use the mysql2 gem. Unfortunately, versions 0.2.x (required for Rails 2.3) and versions 0.3.x (required for Rails 3.2) can no longer be installed on...

...to errors when compiling the native extension, or a segfaults when using it. For Rails 4.2, mysql2 version 0.4.10 seems to work okay. If you still have issues, upgrade to...

masilotti.com

...Fixtures are handy for development seed data, they can be loaded in development with: rails db:fixtures:load Downsides Less matchers & library support It is harder to mock with minitest...

JavaScript files that can be loaded individually from your application layout. By default your Rails application has a single entrypoint application.js, which should import all other files.

github.com

config.assets.digest = false and to features/support/capybara.rb: # Have HTML screenshot render with assets (while `b rails s` is running) Capybara.asset_host = 'http://localhost:3000' You might want to replace localhost with...

...create only the records needed for the test. Learn Factories, not fixtures By default Rails uses global fixtures for its tests. This is a giant world of example data that...

...other gems in the past, but they all work in the same way. Watch Railscasts PRO #158 Factories not Fixtures (revised) for an introduction to factories in general and FactoryBot...

...generated for associations. Warning Don't use query_attribute on associations. In case of Rails 7 you are getting an error. In Rails 6 this method is always responding with...

Understand that each call of a cron job will boot up your Rails application and produce 100% load on a CPU during booting. Talk to your mentor what...

geekytidbits.com

ORDER BY category DESC, created_at; The easiest options to achieve this in Rails ActiveRecord is to use "WHERE ID IN" with User.where(id: Post.distinct_on_user.pluck(:user_id)).order(...)