Skip to content

Instantly share code, notes, and snippets.

#contentButton{ :class => cycle('first ','second ','third ') + blurb.id.to_s }
= image_tag('ancillary/ribbon_top.png', :class => 'ribbonTop')
= image_tag('ancillary/ribbon_bottom.png', :class => 'ribbonBot')
= image_tag blurb.image.url, :class => "blurbImage" unless blurb.image.blank?
%p.heading= blurb.name
%p.shortContent= blurb.short_content.presence || nil
.contents= blurb.content
#contentRow <-- This element should only be rendered if this is the 3rd render loop or if it is the last render loop
#contentButton{ :class => cycle_with_last(blurb, @content, options = {:one => 'first ', :two => 'second ', :three => 'third ', :last => 'last '}) + blurb.id.to_s }
= image_tag('ancillary/ribbon_top.png', :class => 'ribbonTop')
= image_tag('ancillary/ribbon_bottom.png', :class => 'ribbonBot')
= image_tag blurb.image.url, :class => "blurbImage" unless blurb.image.blank?
%p.heading= blurb.name
%p.shortContent= blurb.short_content.presence || nil
.contents= blurb.content
= add_row_on_last(blurb, @content)
@jonpaul
jonpaul / model.rb
Created July 8, 2011 16:54
validates is_good
validate :is_valid_time
def valid_time?
self.time > 24.hours.from_now
end
def is_valid_time
errors.add("Your object", "is not valid. Other explainations.") unless valid_time?
end
if ($('div.contentRow').has('#calendar').not('.fc')) {
doCalendar();
console.log('it does');
console.log($('div.contentRow').children())
};
if ($(".contentRow .contents #calendar:not('.fc')").length > 0) {
class EventsController < InheritedResources::Base
respond_to :json, :only => :index
def index
@events = Event.all
respond_with(@events, :only => [:id, :title, :start])
end
@jonpaul
jonpaul / _index.html.haml
Created July 12, 2011 02:58
How do I rewrite this for haml?
<% content_for(:javascript) do %>
locations = [];
<% @locations.each do |loc|%>
locations.push(new google.maps.LatLng(<%=loc.lat%>, <%=loc.lon%>));
<%end%>
<%end%>
@jonpaul
jonpaul / contactu.rb
Created July 12, 2011 14:08
contactu.rb
class Contactu
include ActiveModel::Validations
validates_presence_of :email, :name, :phone, :message
attr_accessor :id, :email, :phone, :name, :message
def initialize(attributes = {})
attributes.each do |key, value|
self.send("#{key}=", value)
@jonpaul
jonpaul / foo.rb
Created July 12, 2011 18:12
quickie example
@supervisor = User.find(1)
@staff = User.find(2)
@supervisor.relationships.build(:staff_id => @staff.id)
def rescue_404
render :file => "#{Rails.root}/public/404.html",
:status => 404, :layout => 'application'
end