Skip to content

Instantly share code, notes, and snippets.

View davidphasson's full-sized avatar

David Hasson davidphasson

  • Los Angeles, CA
View GitHub Profile
# Time specifications:
validates_each :assembly_time2 do |record, attr, value|
next if value.nil?
# Leave this up to other validation
next if record.assembly_time1.nil?
if value < ( record.assembly_time1 + 1.hour + 15.minutes )
record.errors.add attr, "must allow for at least one hour assembly and 15 minute break"
end
end
validates_each :assembly_time3 do |record, attr, value|
<!-- Scroll works on these links -->
<div id="navbar" style="padding: 5px;">
<%= f.tab_button "general", link_to_function("General", "switch_tab('page_general');"), general_fields, { :current => true } %>
<%= f.tab_button "contact", link_to_function("Contact", "switch_tab('page_contact');"), contact_fields %>
<%= f.tab_button "dates", link_to_function("Dates", "switch_tab('page_dates');"), date_fields %>
<%= f.tab_button "times", link_to_function("Times", "switch_tab('page_times');"), time_fields %>
<%= f.tab_button "questions", link_to_function("Questions", "switch_tab('page_questions');"), question_fields %>
<%= f.tab_button "multisite", link_to_function("Multi-School Visits", "switch_tab('page_multisite');"), multisite_fields %>
<%= f.tab_button "comments", link_to_function("Comments", "switch_tab('page_comments');"), comment_fields %>
def new
@request = Request.new
# This needs to go somewhere else
@request.lunch_with_mike = true
end
class Request < ActiveRecord::Base
# Page 1
validates_presence_of :school, :assembly_type, :starting_grade, :ending_grade, :num_students, :author_hosted, :mike_hosted
validates_numericality_of :num_students, :message => "is not a valid number"
# Current hacked validation - 1..4 are radio options, otherwise look for a date
validates_inclusion_of :mike_hosted, :in => (1950..(Date.today.year)).to_a + (1..4).to_a, :message => "is an invalid date"
# :unless => Proc.new { |r| r.varable <test> })
// Operates on tabs with class "form_tab" - hides all but "tabname"
function switch_tab(tabname)
{
tabs = $$('.form_tab');
for ( var i in tabs )
{
tab = tabs[i];
(tabname == tab.id) ? tab.show() : tab.hide();
}
scroll(0,0);
<%= javascript_include_tag "dynamic.1226508100" %>