Design by codemarkie (BBC iPlayer TV Guide inspired)
Forked from Charlie Walter's Pen Calender UI.
A Pen by Thomas ochman on CodePen.
require 'addressable/uri' | |
#Accepts options[:message] and options[:allowed_protocols] | |
class UriValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
uri = parse_uri(value) | |
if !uri | |
record.errors[attribute] << generic_failure_message | |
elsif !allowed_protocols.include?(uri.scheme) | |
record.errors[attribute] << "must begin with #{allowed_protocols_humanized}" |
def choices(array) | |
'[' + array.join('|') + ']' | |
end | |
greetings = choices(%w[Hello Hi Hey]) | |
titles = choices(%w[friend dear]) | |
concerns = choices( | |
[ | |
"are you #{choices(['today', 'these days'])}", | |
"is your #{choices(%w[sister mother father brother])}" |
Design by codemarkie (BBC iPlayer TV Guide inspired)
Forked from Charlie Walter's Pen Calender UI.
A Pen by Thomas ochman on CodePen.
event_instances = Event.find(:all) | |
event_instances.each do |event| | |
schedule = Schedule.from_yaml(event.schedule_yaml) | |
if schedule.occurs_on? Date.today + 5.days | |
#do stuff... | |
#like: | |
event_instance = [event.name, event.start_datetime].join('-') | |
EventInstance.find_or_create_by_name(name: event_instance, category: event.category, description: event.description) | |
#..and whatever information the instance need to inherit from its parent... | |
end |
def store_location | |
if conventional_get_request? && !black_listed_url?(black_listed_urls) | |
session[:previous_url] = request.fullpath | |
end | |
end | |
def clear_stored_location | |
session[:previous_url] = nil | |
end |
##Methods for legacy password handling with Devise | |
def valid_password?(password) | |
if has_legacy_password? | |
return false unless valid_legacy_password?(password) | |
convert_legacy_password!(password) | |
true | |
else | |
super(password) | |
end | |
end |
<fieldset class="event_option" id="repeats_monthly_options"> | |
<%= f.number_field :repeats_every_n_months %> | |
<%= f.select :repeats_monthly, Event::RepeatMonthlyOptions %> | |
<div class="control-group" id="event_repeats_monthly_each"> | |
<label class="control-label">Each</label> | |
<div class="controls"> | |
<% Event::DaysOfTheMonth.each do |day_of_the_month| %> | |
<%= label_tag "event_repeats_monthly_each_days_of_the_month_#{day_of_the_month}", day_of_the_month, :class => 'checkbox inline' do %> | |
<%= check_box_tag "event[repeats_monthly_each_days_of_the_month][#{day_of_the_month}]", day_of_the_month, f.object.repeats_monthly_each_days_of_the_month.include?(day_of_the_month), {:name => "event[repeats_monthly_each_days_of_the_month][]"} %> | |
<%= day_of_the_month %> |
require 'spec_helper' | |
describe EventHelper do | |
it 'cover_for PairProgramming' do | |
event = mock_model(Event, category: 'PairProgramming') | |
result = helper.cover_for(event) | |
expect(result).to match /event-pairwithme-cover\.png/ | |
end | |
it 'cover_for Scrum' do |