An incomplete cheatsheet for rails 3. Things are added as they are required.
# http://guides.rubyonrails.org/active_record_validations_callbacks.html
class SomeClass < ActiveRecord::Base
# length
http://erniemiller.org/projects/squeel/ | |
* KeyPaths | |
Person.joins(:articles => {:comments => :person}) => Person.joins(articles.comments.person) | |
-> they can also exist in the context of a hash | |
* Predicates | |
SQL Predication Operator Alias | |
= eq == |
' | |
rails 1.9 new hash syntax | |
new_hash = {simon: "Talek", lorem: "Ipsum"} | |
###Rspec | |
%cucumber | |
save_and_open_page | |
###MIGRATION |
more: https://github.com/justinfrench/formtastic | |
-> make form for all db columns | |
<%= semantic_form_for @user do |f| %> | |
<%= f.inputs %> | |
<%= f.buttons %> | |
<% end %> | |
-> select cols | |
<%= semantic_form_for @user do |f| %> |
@mixin ie6 { * html & { @content } } | |
#logo { | |
background-image: url("/images/logo.png"); | |
@include ie6 { background-image: url("/images/logo.gif"); } | |
} |
class FuiBooleanInput < SimpleForm::Inputs::BooleanInput | |
self.default_options = {:input_html => {'data-toggle' => "checkbox"}, :inline_label => true, :label => false} | |
def nested_boolean_style? | |
true | |
end | |
end |
# nonlinear scrolling of idea attachments | |
# we want to make it like the scrolling pauses on each attachment | |
# for this we create an empty wrapper with the same width, height and use a fixed positioning for attachments container | |
# this way we can freely decide where to position them based on window's scroll position, and the wrapper will keep the | |
# preserved space in the document | |
$(window).on 'scroll', -> | |
container = $('.nonlinear-scroll') | |
wrapper = $('.nonlinear-scroll-wrapper') | |
breathePoints = $('.nonlinear-scroll-breathe-point') |
Simple css vertical dividers you can easily adapt to the grid system of your liking.
Forked from Phil Hoyt's Pen Vertical Dividers between Columns.
A Pen by Captain Anonymous on CodePen.
=def-classes($attr, $values...) | |
@each $val in $values | |
.#{$attr}-#{$val} | |
#{$attr}: #{$val} | |
@each $d in 0,1,2,4,8,16 | |
@each $attr in margin, padding | |
.#{$attr}-#{$d}, .childs-#{$attr}-#{$d} > * | |
#{$attr}: #{$d}em |
A Pen by Captain Anonymous on CodePen.