This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |