Não use UUID como PK nas tabelas do seu banco de dados.
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
| # rails console | |
| ActiveRecord::Base.connection.tables.each do |table| | |
| indexes = ActiveRecord::Base.connection.indexes(table) | |
| if indexes.length > 0 | |
| puts "====> #{table} <====" | |
| indexes.each do |index| | |
| puts "----> #{index.name}" | |
| end | |
| puts "====> #{table} <====" |
The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.
First the simplest/core layers, then optional layers depending on which features/functionality you want.
Specs |
|
|---|---|
| AUTHOR | Ira Herman |
| LANGUAGE/STACK | Ruby on Rails Version 4, 5, or 6 |
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
| Warden::Manager.before_failure do |env, opts| | |
| # Sinatra/Padrino is very sensitive to the request method and | |
| # since authentication could fail on any type of method, we need | |
| # to set it for the failure app so it is routed to the correct block. | |
| env['REQUEST_METHOD'] = "POST" | |
| end | |
| Warden::Strategies.add(:basic_http) do | |
| def valid? | |
| # Check if valid and store an instance var |
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :developmentThen you'll want to rebuild your Docker container to install the gems
YouTube video: https://www.youtube.com/watch?v=r-8isv_TnVA
Codesandbox: https://codesandbox.io/s/vanilla-js-masks-45ff8n
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
| http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
| http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
| #payload: [{"kind"=>"person"}] | |
| Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
| #data: {"interest"=>["music", "movies", "programming"]} | |
| Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
| Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
| Segment.where("jsonb_array_length(data->'interest') > 1") |
This list is based on aliases_spec.rb.
You can see also Module: RSpec::Matchers API.
| matcher | aliased to | description |
|---|---|---|
| a_truthy_value | be_truthy | a truthy value |
| a_falsey_value | be_falsey | a falsey value |
| be_falsy | be_falsey | be falsy |
| a_falsy_value | be_falsey | a falsy value |