Skip to content

Instantly share code, notes, and snippets.

View jcutrell's full-sized avatar

Jonathan Cutrell jcutrell

View GitHub Profile
@jcutrell
jcutrell / base_job.rb
Last active August 29, 2015 14:19
Weird behavior...
class BaseJob < ActiveRecord::Base
belongs_to :child_job, polymorphic: true
has_attached_file :header_image, :styles => { :medium => "800x500#" }
validates_attachment_content_type :header_image, :content_type => /\Aimage\/.*\Z/
validates :title, presence: true
validates :prompt_html, presence: true
@jcutrell
jcutrell / a1.md
Last active August 29, 2015 14:20 — forked from r00k/a1.md

Answer to Question 1

That code violates Tell, Don't Ask..

You could also say it exhibits the feature envy smell.

Furthermore, "checking systems" shouldn't, necessarily, sound an alarm. The method both checks and responds to a state, and therefore has side effects. You might prefer to ONLY check the system without sounding an alarm.

(Violating Tell, Don't Ask and having feature envy are pretty much two sides of the same coin.)

Started GET "/admin/users/2/accept_by_token?user_email=bob%40whiteboard.is&user_token=SkszoGBFgz_uhP-xQU3g" for 127.0.0.1 at 2016-06-02 13:50:19 -0400
Processing by Admin::UsersController#accept_by_token as HTML
Parameters: {"user_email"=>"[email protected]", "user_token"=>"SkszoGBFgz_uhP-xQU3g", "id"=>"2"}
[1m[35mUser Load (0.5ms)[0m SELECT "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["email", "[email protected]"]]
[1m[36mCACHE (0.0ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT 1[0m [["email", "[email protected]"]]
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 2]]
[1m[36m (0.1ms)[0m [1mSAVEPOINT active_record_2[0m
[1m[35mSQL (0.3ms)[0m UPDATE "users" SET "application_status" = $1, "updated_at" = $2 WHERE "users"."id" = $3 [["application_status", 3], ["updated_at", "2016-06-02 17:50:19.320888"], ["id", 2]]
[1m[36m (0.1ms)[0m [1mRELEASE SA

Keybase proof

I hereby claim:

  • I am jcutrell on github.
  • I am jcutrell (https://keybase.io/jcutrell) on keybase.
  • I have a public key ASDGeZWubxMA-dEx5ByX3eDJ4zzRafoPc4gPkVJSxOKh2Qo

To claim this, I am signing this object: