Skip to content

Instantly share code, notes, and snippets.

= semantic_form_for @pet do |form|
= form.inputs do
= form.input :animal
= form.input :diseases, :as => :check_boxes, :value_as_class => true
= form.buttons
= semantic_form_for @user_profile, :url => user_user_profile_path(@user), :html => {:multipart => true} do |form|
%p.large Personal information
%hr.profile
%p.smlTitle Phone Number
= form.inputs do
= form.semantic_fields_for :profile_phones do |phone|
= render 'profile_phone_fields', :form => phone
= link_to_add_fields "Add Phone", form, :profile_phones, "addPhone"
= form.buttons
/* Main navigation elements.
-------------------------------------------------------------- */
#Nav {height:45px;background:transparent}
#Nav ul {list-style:none;margin:10px 0 0 7px}
#Nav ul li {display:inline}
#Nav ul li a {list-style-type:none;display:inline-block;padding:10px 20px;color:#a1a1a1;background:#f4f4f4;border:1px solid #d1d1d1;text-transform:uppercase;-moz-border-radius:4px;-webkit-border-radius:4px;-moz-box-shadow:0 1px 3px #f1f1f1;-webkit-box-shadow:0 1px 3px #f1f1f1}
/*
This is a pretty crappy brief to tout the benefits of "good CSS", "good SASS",
"good OOCSS" or anything else, but let's roll with it for now.
*/
#Nav {height:45px;background:transparent}
#Nav ul {list-style:none;margin:10px 0 0 7px}
#Nav ul li {display:inline}
#Nav ul li a {list-style-type:none;display:inline-block;padding:10px 20px;color:#a1a1a1;background:#f4f4f4;border:1px solid #d1d1d1;text-transform:uppercase;-moz-border-radius:4px;-webkit-border-radius:4px;-moz-box-shadow:0 1px 3px #f1f1f1;-webkit-box-shadow:0 1px 3px #f1f1f1}
@justinfrench
justinfrench / gist:999715
Created May 31, 2011 01:12
Did you know you can pass classes into Rails tag helpers as Arrays?
# Let's say you've programatically built up an array of classes for a HTML element:
my_classes = [:a, :b, 'c']
# Don't do this, join(" ") is for chumps:
<% content_tag(:p, "Foo", :class => my_classes.join(" ")) %>
# Winners do this:
<% content_tag(:p, "Foo", :class => my_classes) %>
# => <p class="a b c">Foo</p>
<% link_to("Foo", foos_path, :class => my_classes) %>
@justinfrench
justinfrench / gist:999731
Created May 31, 2011 01:27
Did you know there's a less painful way to do data attributes in Rails?
# This has very little win:
<%= content_tag(:p, "Foo", "data-bah" => "...", "data-baz" => "...") %>
# Some chumps make it even more noisy:
<%= content_tag(:p, "Foo", :"data-bah" => "...", :"data-baz" => "...") %>
# I was going to patch Rails to convert :data_bah to "data-bah"
<%= content_tag(:p, "Foo", :data_bah => "...", :data_baz => "...") %>
# But they already do this:
@justinfrench
justinfrench / formtastic_extentions.rb
Created June 16, 2011 23:40 — forked from rhulse/formtastic_extentions.rb
Formtastic 2.0 custom input upgrade examples
# This file contains custom input method from formtastic 1.2 and their
# replacement classes in 2.0
module FormtasticExtensions
class WysiwygInput < Formtastic::Inputs::TextInput
def input_html_options
wysiwyg_type = input_options.delete(:controls)
@justinfrench
justinfrench / .gitconfig
Created January 6, 2012 10:36
Git aliases for tracking and publishing git branches (usage: `git publish`)
[alias]
current-branch = !git branch | grep '^*' | sed s/\\*\\ //
track = !git branch --set-upstream $(git current-branch) origin/$(git current-branch)
publish = !git push origin $(git current-branch) && echo $(git track)
# PRODUCT MODEL
has_many :product_people
has_many :people, :through => :product_people
accepts_nested_attributes_for :people
<%= f.inputs "Cast" do %>
<%= f.inputs :for => :people do |p| %>
<%= p.input :name %>
<%= p.input :_destroy, :as => :boolean %>
@justinfrench
justinfrench / gist:1777140
Created February 9, 2012 03:53
Target modern browsers with the :not selector
.something {
rules for older browsers like IE6–8
}
.something:not(.crappy) {
extra rules for any browser that supports :not selector
the .crappy class is a hack, but it feels appropriate
}