Skip to content

Instantly share code, notes, and snippets.

View radar's full-sized avatar

Ryan Bigg radar

View GitHub Profile

NoMethodError at /coders
undefined method `time_counter' for #<Coder:0x007f8d5def4a88>

views/coders/index.html.erb

<% @coders.each do |coder| %>
  <div class="post_item">
    <%= image_tag coder.cover_image, class:"cover_image_index" %>
    <div class="index_title"><%= sanitize coder.title %></div>
    <div class="index_description"><%= sanitize coder.description %></div>
class Player
def initialize(name, health = 100, rank = 1)
@name = name.capitalize
@health = health
@rank = rank
end
def say_hello
puts "#{@name} has #{@health} health and #{@rank} rank."
@radar
radar / route.rb
Last active August 29, 2015 14:10 — forked from 1dolinski/route.rb
controller "posts" do
scope path: "/posts/:id" do
post "one"
delete "two"
end
end
# same as
post "/posts/:id/one", to: "posts#one"
def current_user
begin
@current_user ||= User.find(session[:user_id]) if session[:user_id]
rescue ActiveRecord::RecordNotFound
reset_session
end
end
helper_method :current_user
def create
begin
params[:referral][:dob] = Date.strptime(params[:referral][:dob], '%m/%d/%Y')
rescue ArgumentError
# error goes here
end
@referral = Referral.new(referral_params)
require 'open-uri'
require 'nokogiri'
require 'rails'
url = "http://eveboard.com/pilot/Livid_Retreat"
data = Nokogiri::HTML(open(url))
skill = data.at_css('.dotted')
def mode(array)
hash = Hash.new(0)
array.each do |i|
hash[i]+=1
end
return hash.max.select{|x, y| x }
end
class Date
def to_words
today = Date.today
case self
when today
"Today"
when today - 1
"Yesterday"
when today + 1
@radar
radar / gist:13400
Created September 28, 2008 02:26 — forked from anonymous/gist:13399
class SubscriptionConfirm < ActiveRecord::Base
@@confirm_sent = Hash.new
def initialize(params = nil)
super(params)
set_default_values
end
def self.subscribe_to_newsletter(params = nil)
@radar
radar / gist:33867
Created December 9, 2008 10:30 — forked from anonymous/gist:33866
desc 'Create YAML test fixtures from data in the existing database.'
task(:extract_fixtures => :environment) do
sql = "SELECT * FROM %s ORDER BY desc(id) LIMIT 10"
skip_tables = ["schema_info", "badges", "badge_groups", "html_links", "hero_plus_status_updates"]
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
i = "000"
File.open("#{RAILS_ROOT}/test/fixtures/#{table_name}.yml", 'w') do |file|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
file.write data.inject({}) { |hash, record|