...or Rack::SteadyETag). Those middlewares usually want to capture the entire response body in order to generate the ETag based on its contents. If they do that, you won't...

...Here is the list of features we want to achieve: Paginated (using will_paginate) Ordered by translated name of departure_place and arrival_place No N+1 queries

...normally straightforward, but as we are referencing the table we want to order on twice some adjustments need to be made. Ride .joins('inner join places as departure_places on...

...user tables without changing existing passwords Use salts to disarm brute force attacks. In order to let users keep their passwords, hash passwords as before, then hash the result again...

wiki.postgresql.org

...nspname NOT IN ('pg_catalog', 'information_schema') AND C.relkind <> 'i' AND nspname !~ '^pg_toast' ORDER BY pg_total_relation_size(C.oid) DESC LIMIT 5; Example output: relation | total_size ----------------------+------------ public.snapshots...

...UTC). Actually, you cannot "turn off" time zones, just try to ignore them. In order to disable time zone conversion in Rails 2, open config/environment.rb and comment or remove the...

...config.time_zone line: # config.time_zone = 'Berlin' In order to disable time zone conversion in Rails 3 or newer, open config/application.rb and add the following: config.active_record.default_timezone = :local config.active_record.time_zone_aware...

...in the project before, starting many thousand of jobs might reveal unexpected issues: Wrong order of sidekiq queues: Your queue might block the whole application and monitoring. Monitoring or mailer...

makandra dev
stackoverflow.com

field.ancestor('div.form-group') Both versions will return the outermost matching element. Use the #order option find the closest parent: field.ancestor('div.form-group', order: :reverse...

...when parsing your HTML string. As long as tags are closing in the correct order, you should be fine. However, when converting back to an HTML string, you may end...

When paginating records, we usually need to know the number of total records in order to render pagination links. Popular pagination libraries like will_paginate or Kaminari do this for...

...in the subdirectory controllers/users/sign_ups_controller.rb, but there has to be a SignUpsController in controllers/sign_ups_controller.rb in order to make the second example work. You can alter this behaviour with a custom controller...

end resources :projects, only: :show Note that the routes must appear in this order so projects/report won't match the :projects resource. Run rake routes and you get what...

docs.gitlab.com

Use rules to include or exclude jobs in pipelines. Rules are evaluated in order until the first match. When a match is found, the job is either included or excluded...

makandracards.com

In order to have more human readable git branches, do git pull --rebase To always pull like this, write these lines to your ~/.gitconfig: [pull] rebase = true

...existing rows with ascending numbers. Furthermore these numbers should be generated by a special order. In order to achieve that you could do the following: execute "SET @pos := 0;"

...UPDATE pages SET position = ( SELECT @pos := @pos + 1 ) ORDER BY updated_at DESC...

makandra dev

...after pagination: # does not work @contracts = @contracts.reject {...} # works @contracts.reject! {...} YAML fixes Change # old date: order: [ :day, :month, :year ] # new date: order: - :year - :month - :day Also see Upgrade from Ruby...

...Many times you would use scope options, like this: users = User.scoped( :joins => 'INNER JOIN orders joined_orders ON users.id = joined_orders.user_id', :conditions => [ 'joined_orders.date BETWEEN ? AND ?', start_date, end_date ],

...user IDs by selecting only from the users table: users = User.scoped( :joins => 'INNER JOIN orders joined_orders ON users.id = joined_orders.user_id', :conditions => [ 'joined_orders.date BETWEEN ? AND ?', start_date, end_date ],

Let's say you have two XML strings that are ordered differently but you don't care about the order of attributes inside containers: a = ' batman secret ' b = ' secret batman...

xml_parser.parse(a) => {:authenticate=>{:user=>"batman", :password=>"secret"}} xml_parser.parse(a) == xml_parser.parse(b) => true Note: order in XML can be important (e.g. XHTML). For cases where it's not, you can...

...necessarily) only happen when trying to update or otherwise lock several rows in different order. Solving deadlocks is potentially complicated, so here are a few pointers: MySQL should always detect...

...the necessary parameters instead. that is for example caused by url_for( :overwrite_params => { :order => 'name', :dir => 'asc' } ) you can fix this by using params.merge {:my_param_to_overwrite => 'foo...

...To fix the example above the code could look like: url_for( params.merge { :order => 'name', :dir => 'asc' } ) Note: link_to uses url_for internally, so you can can use params.merge...

makandra dev

...special tag message" A normal git push will not push the tag. So in order to publish your (local) tags, you have to git push --tags Check if a tag...

Stick.shuffled.first Or, if you prefer something smaller: class Stick named_scope :shuffled, :order => 'RAND()' end Note however that you should never order by RAND() on tables that may...

...t magically load themselves from disk. Production All files are loaded in a deterministic order once the server boots. Take this example with some constants referencing each other: # app/models/contract/document/uploader.rb

...Document::Uploader. In development this can happen randomly, as you never know in which order the files are autoloaded. If the autoload mechanism has already loaded app/models/document/uploader.rb, a constant lookup...

...In most cases it is sufficient to delete and recreate the local database in order to import the dump. If any problems occur, proceed as follows: 1. Figure out the...

postgresql.org

...If you use the ARRAY[] syntax, you'll need to add a type in order to perform operations with e.g. a string array column: ARRAY['one', 'two']::varchar[].

...always bypass the pre-commit hook by committing with the --no-verify option.) In order to have git fix whitespace on lines you edited before each commit, append the following...