Skip to content

Instantly share code, notes, and snippets.

View mikebaldry's full-sized avatar

Michael Baldry mikebaldry

View GitHub Profile
namespace :db do
desc "Rolls the schema back to the previous version. Specify the number of steps with STEP=n"
task :rollback => :environment do
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
version = ActiveRecord::Migrator.current_version - step
ActiveRecord::Migrator.migrate('db/migrate/', version)
end
end
tag_method_map = {"string" => :text_field_tag, "text" => :text_area_tag, "integer" => :number_field_tag}
tag_method = tag_method_map[options[:type]]
input = @template.send(tag_method, options[:name], "", :class => options[:input_class], :required => options[:required] ? "required" : nil)
def active_class(controller, action = nil)
active = params[:controller] == controller.to_s &&
(action.nil? || params[:action] == action.to_s)
active ? "active" : nil
end
def nav_link(link_text, controller)
content_tag(:li, :class => active_class(controller, action) do
link_to link_text, controller
def active_if(controller, action = nil)
active = params[:controller] == controller.to_s &&
(action.nil? || params[:action] == action.to_s)
active ? "active" : nil
end
(rdb:1) pp nil ; 43
nil
*** Unknown command: " 43". Try "help".
class Server
def self.all
load_all_server_info_from_api.collect { |server_info| Server.new(server_info) }
end
def name
@server_info.name
end
def alive?
resources :cars, :except => :index do
collection do
post :index
end
member do
get :registration_details
end
end
$netRevenueTd = $tr.find("td[data-property='net_revenue']")
if ddr.properties.net_revenue_estimated
$netRevenueTd.addClass("estimated")
else
$netRevenueTd.removeClass("estimated")
def is_votable?
return false unless active
running?
end
def time_boxed?
starting_at.nil? && ending_at.nil?
end
def running?
SELECT `campaigns`.* FROM `campaigns`
WHERE
(
(
(media_plan_lines.start_at <= '2012-09-21'
AND
media_plan_lines.end_at >= '2012-09-21')
OR
(DATEDIFF(CURDATE(), media_plan_lines.end_at) <= 10)
)