This file contains hidden or 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
def index | |
# Queries are here for clarity purposes in this demo | |
# It's of course a better idea to create a method in your model | |
users = User.find(:all) do | |
# Neato! | |
if params[:_search] == "true" | |
pseudo =~ "%#{params[:pseudo]}%" if params[:pseudo].present? | |
firstname =~ "%#{params[:firstname]}%" if params[:firstname].present? |
This file contains hidden or 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
<div class="weekly_builder"> | |
<div class="week"> | |
<div class="days"> | |
<div class="placeholder"> | |
<div class="day"> | |
... | |
.weekly_builder .week{background:#FFF;width:100%;height:100%;border:1px solid #ccc;overflow:hidden;} |
This file contains hidden or 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
- In HEAD | |
:javascript | |
jQuery(document).ready(function($){ | |
#{yield :ready} | |
}); | |
- In VIEW | |
- content_for :ready do |
This file contains hidden or 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
desc "Cleanup characters" | |
task :cleanup => :environment do | |
ContentItem.all.each do |item| | |
item.update_attribute :body, item.body.gsub('’', "'") unless item.body.blank? | |
end | |
end |
This file contains hidden or 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
# F MS Word | |
# This will cleanup 95% of the issues of copying from Word into a textarea. | |
# Notes: | |
# - This would be run on text already saved to the database | |
# - I am using Markdown convention for the bullets | |
# - I am being very lazy with em/en dashes - I could use Smarty Pants, but that opens up other issues | |
class WordCleanup | |
def self.clean(text) | |
unless text.nil? |
This file contains hidden or 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
# this allows you to use a CNAME for multiple environments | |
# Paperclip only supports multiple access, secret access and bucket | |
# in your model... | |
has_attached_file :attachment, | |
:path => ":class/:id/:style_:basename.:extension", | |
:storage => :s3, | |
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml", | |
:s3_host_alias => YAML.load_file("#{RAILS_ROOT}/config/s3.yml")[RAILS_ENV]["s3_host_alias"], |
This file contains hidden or 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
require 'hirb' | |
module Hirb | |
module Console | |
# Simple shortcut to grab a few columns in irb | |
# Note that you can only use column names | |
# Usage: | |
# tab Article.all, :id, :title, :published_at | |
def tab(output, *fields) | |
max_width = case fields.size |
This file contains hidden or 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
# in layout... | |
:javascript | |
jQuery(document).ready(function($){ | |
#{yield :ready} | |
}); | |
# in view... | |
- content_for :ready do |
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Slides</title> | |
<script src="jquery-1.3.2.js" type="text/javascript" charset="utf-8"></script> | |
<script type='text/javascript'> |
This file contains hidden or 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
# needs refactored...but not today | |
module ApplicationHelper | |
def display_address(obj, args = {}) | |
args = { | |
:address_1 => obj.respond_to?('address_1') ? obj.address_1 : obj.address1, | |
:address_2 => obj.respond_to?('address_2') ? obj.address_2 : obj.address2, | |
:city => obj.city, | |
:state => obj.respond_to?('state_abbrev') ? obj.state_abbrev : obj.state, |