-
[Act with Prudence](http://programmer.97things.oreilly.com/wiki/index.php/Act with Prudence)Notes: Act with prudence and not accrue technical debt by accomplishing things in a quick and dirty manner.
-
Ask "What Would the User Do?" (You Are not the User)Notes: We as programmers don't see things the same way as the users do. Need to get better at seeing past one's own experience / perceptions, and learn to see things the way users do. Best way to gather requirements is to watch users do the same activity - better than asking them about it.
-
[Automate Your Coding Standard](http://programmer.97things.oreilly.com/wiki/index.php/Automate Your Coding Standard)
This file contains 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
class MyObject < ActiveRecord::Base | |
... | |
protected | |
def self.find(*args) | |
if results = super(*args) | |
# Code to add stuff to the my_object.extra_data object | |
... | |
end |
This file contains 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
An ActionController::InvalidAuthenticityToken occurred in user_sessions#create: | |
ActionController::InvalidAuthenticityToken | |
------------------------------- | |
Stack Trace | |
------------------------------- | |
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): | |
actionpack (4.2.0) lib/action_controller/metal/request_forgery_protection.rb:181:in `handle_unverified_request' | |
actionpack (4.2.0) lib/action_controller/metal/request_forgery_protection.rb:209:in `handle_unverified_request' |
This file contains 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
class ApplicationController < ActionController::Base | |
protect_from_forgery with: :exception | |
rescue_from ActionController::InvalidAuthenticityToken, with: :show_errors | |
before_filter { |c| User.current_user = c.current_user } | |
... | |
private | |
def show_errors |
add_foreign_key
seems to be behaving inconsistently when it is called with rake db:rollback
.
When called from rake db:migrate
, a custom name built with table name & column name is used for the index name.
When called from rake db:rollback
, the name used for the index is a generic one.
Here is the diff from the above behavior in my db/schema.rb
file:
- add_index "line_items", ["location_id"], name: "index_line_items_on_location_id", using: :btree
+ add_index "line_items", ["location_id"], name: "fk_rails_4335959382", using: :btree
This file contains 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
class ExampleMailer < ActionMailer::Base | |
default bcc: "[email protected]" | |
... | |
end |
[master] $ git bisect start
[master] $ git bisect good fd65a9000b550509358dfdcd557c0bb882630d4e
[master] $ git bisect bad 4e961ca184d39bcc3755d017e94bf03c6e656b29
Bisecting: a merge base must be tested [ee614af6fa6c9e8cac70bcfd7d3583d0b4ff907b] Merge pull request #17812 from jonatack/patch-8 [(no branch, bisect started on master)] $ git bisect good
This file contains 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
cap aborted! | |
NoMethodError: undefined method `already_invoked' for <Rake::Task load:defaults => []>:Rake::Task | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/lib/capistrano/dsl.rb:16:in `invoke' | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/lib/capistrano/application.rb:91:in `load_imports' | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:697:in `raw_load_rakefile' | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:94:in `block in load_rakefile' | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling' | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:93:in `load_rakefile' | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:77:in `block in run' | |
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling' |
This file contains 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
############################################################################## | |
# decimal_rounding_error.rb | |
# Script for https://github.com/rails/rails/issues/26108 | |
############################################################################## | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end |
This file contains 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
# activerecord/test/cases/decimal_rounding_test.rb | |
require "cases/helper" | |
require "models/thing" | |
class DecimalRoundingTest < ActiveRecord::TestCase | |
ActiveRecord::Schema.define do | |
create_table :things, force: true do |t| | |
t.decimal :price, precision: 4, scale: 4 | |
end | |
end |