Skip to content

Instantly share code, notes, and snippets.

View kalleth's full-sized avatar

Tom Russell kalleth

View GitHub Profile
require 'date'
require 'twitter'
require 'dotenv'
Dotenv.load
class TwitterSearch
def fetch(query)
client.search("#{query} since:#{Date.today}").collect do |tweet|
Tweet.new(tweet)
end
# my controller
def create
@uid = Uid.find_by(number: uid_params[:number])
if @uid
update
else
@uid = Uid.new(uid_params)
if @uid.save
puts "Uid is #{@uid.inspect}"
class CreateLoginRecords < ActiveRecord::Migration
def self.up
create_table :login_records do |t|
t.integer :user_id
t.datetime :logged_in
t.timestamps
end
add_index(:login_records, :user_id)
add_index(:login_records, :logged_in)
class Account < ActiveRecord::Base
has_many :users
accepts_nested_attributes_for :users
serialize :account #If you want to store the recurly account, you need to serialise the object
validates_presence_of :company, :on => :create, :message => "can't be blank"
# Before_create will be called once only
before_create :create_external_account