code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
module StocksHelper
end
| Ruby |
module DashHelper
end
| Ruby |
class Match < ActiveRecord::Base
has_many :users_matches, class_name: 'UsersMatch'
has_many :users, through: :users_matches
validates_numericality_of :startmoney, :allow_nil => false,
:greater_then => 0, :message => "The value of start money must be greather than zero."
#checking that the own... | Ruby |
class UsersMatch < ActiveRecord::Base
belongs_to :user
belongs_to :match
serialize :stocks, Hash
def getQuote(s)
url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#{s}%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatata... | Ruby |
class User < ActiveRecord::Base
has_many :users_matches
has_many :watched_stocks, dependent: :destroy
has_many :matches, through: :users_matches
validates :username, :presence => true, :uniqueness => true, :length => { minimum: 5 }
validate :password, :confirmation => true
attr_accessor :password_conf... | Ruby |
class Transaction < ActiveRecord::Base
has_one :user
has_one :stock
#I looked in the view for transactions and saw that the input to decide
# whether the transaction type was a buy or sell was input into a textbox.
# Correct me if I am wrong on that. If it is a textbox entry then I thought it
... | Ruby |
class Stock < ActiveRecord::Base
# not really sure if this needs to be validated or not. Stock information populated...
validates :name, :prescence => true
validates :price :prescence => true
validates :type :prescence => true
validates :volume :prescence => true
validates :time :prescence =... | Ruby |
class Friend < ActiveRecord::Base
has_many :friend
#checking for basic prescence for both attributes here.
validates :user_id, :presence => true
validates :friend_id, :presence => true
#checking that user id and friend id are valid users in the users table.
validate :user_check_id
def user_check_id... | Ruby |
class WatchedStock < ActiveRecord::Base
belongs_to :users
end
| Ruby |
class DashController < ApplicationController
def landing_page
#First page we should load is the login
redirect_to login_url
end
def analytics #The analytics side is handled through jQuery.
@stockClicked = params["symbol"] if params["symbol"]
end
def dashboard #
... | Ruby |
require 'date'
class GameController < ApplicationController
def cents_to_s(c)
"#{c/100}.#{(c/10)%10}#{c%10}"
end
def overview
@quickWatch = self.getWatchedStocks(@current_user.id)
self.changeQuickwatch if request.post? and params['symbol']
@m = Match... | Ruby |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :initializeErrors
before_filter :authorize
before_filter :getGames
protected
def initializeE... | Ruby |
class UsersController < ApplicationController
skip_before_filter :authorize, :only => [:login, :register]
skip_before_filter :getGames, :only => [:login, :register]
protect_from_forgery except: :login, except: :register
def login
if request.post? then
username = ActionController::... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
StockUp::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Us... | Ruby |
class AddJoinedToUsersMatches < ActiveRecord::Migration
def change
add_column :users_matches, :joined, :boolean
end
end
| Ruby |
class AddConfirmedToFriends < ActiveRecord::Migration
def change
add_column :friends, :confirmed, :boolean
end
end
| Ruby |
class RemoveDateregFromUsers < ActiveRecord::Migration
def change
remove_column :users, :datereg, :text
end
end
| Ruby |
class CreateWatchedStocks < ActiveRecord::Migration
def change
create_table :watched_stocks do |t|
t.string :symbol
t.integer :user_id
t.timestamps
end
end
end
| Ruby |
class AddFriendIdToMatches < ActiveRecord::Migration
def change
add_column :matches, :friend_id, :integer
end
end
| Ruby |
class CreateFriends < ActiveRecord::Migration
def change
create_table :friends do |t|
t.integer :user_id, null: false
t.integer :friend_id, null: false
t.timestamps
end
end
end
| Ruby |
class RenameHashToHashedpassword < ActiveRecord::Migration
def change
rename_column :users, :hash, :hashed_password
end
end
| Ruby |
class AddTimeallotedToMatches < ActiveRecord::Migration
def change
add_column :matches, :timealloted, :timestamp
end
end
| Ruby |
class AddFieldsTo < ActiveRecord::Migration
def change
add_column :users_matches, :money, :integer
add_column :users_matches, :stocks, :string
add_column :users_matches, :updated_at, :datetime
end
end
| Ruby |
class AssociateMatchesAndUsers < ActiveRecord::Migration
def change
create_table :match_user do |t|
t.belongs_to :match
t.belongs_to :user
end
end
end
| Ruby |
#author: adam wheeler
class AddIndeces < ActiveRecord::Migration
def change
add_index :friends, :user_id
add_index :friends, :friend_id
add_index :matches, :owner
add_index :users_matches, :match_id
add_index :users_matches, :user_id
add_index :watched_stocks, :user_id
end
end
| Ruby |
class AddSaltToUsers < ActiveRecord::Migration
def change
add_column :users, :salt, :string
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.text :username, null: false
t.text :password, null: false
t.text :firstname
t.decimal :totalmoney, :precision => 8, :scale => 2
t.integer :rank
t.timestamp :datereg, null: false
t.text :em... | Ruby |
class RemoveTimeFromTransactions < ActiveRecord::Migration
def change
remove_column :transactions, :time, :text
end
end
| Ruby |
class RemoveFriendIdFromMatches < ActiveRecord::Migration
def change
remove_column :friend_id, :transaction_id
end
end
| Ruby |
class AddStartmoneyToMatches < ActiveRecord::Migration
def change
add_column :matches, :startmoney, :decimal
end
end
| Ruby |
class AddTimestartedToMatches < ActiveRecord::Migration
def change
add_column :matches, :timestarted, :timestamp
end
end
| Ruby |
class AddChangeToUserMatch < ActiveRecord::Migration
def change
add_column :users_matches, :change, :string
end
end
| Ruby |
class AddCapitalToUsersMatch < ActiveRecord::Migration
def change
add_column :users_matches, :capital, :integer
end
end
| Ruby |
class ChangeTimeallotedFormatInMatches < ActiveRecord::Migration
def change
change_column :matches, :timealloted, :integer
end
end
| Ruby |
class RenamePasswordToHash < ActiveRecord::Migration
def change
rename_column :users, :password, :hash
end
end
| Ruby |
class AddLastQuotedToUsers < ActiveRecord::Migration
def change
add_column :users_matches, :last_quoted, :datetime
end
end
| Ruby |
class FixGameOwnerName < ActiveRecord::Migration
def change
rename_column :matches, :user_id, :owner
end
end
| Ruby |
class CreateStocks < ActiveRecord::Migration
def change
create_table :stocks do |t|
t.text :name, null: false
t.decimal :price, null: false, precision: 8, scale: 2
t.text :type, null: false
t.integer :volume, null: false
t.timestamp :time, null: false
t.timestamps
end
en... | Ruby |
class CreateMatches < ActiveRecord::Migration
def change
create_table :matches do |t|
t.text :title, null: false
t.integer :user_id
t.integer :transaction_id
t.timestamp :timeleft, null: false
t.timestamps
end
end
end
| Ruby |
class RemoveFriendidFromMatches < ActiveRecord::Migration
def change
remove_column :matches, :friend_id
remove_column :matches, :transaction_id
end
end
| Ruby |
class FixColumnName < ActiveRecord::Migration
def change
rename_column :matches, :timestarted, :begintime
end
end
| Ruby |
class CreateTransactions < ActiveRecord::Migration
def change
create_table :transactions do |t|
t.integer :user_id
t.integer :stock_id
t.text :transtype
t.integer :quantity
t.timestamp :time
t.decimal :money
t.timestamps
end
end
end
| Ruby |
class AddLastfetchedToUsersMatch < ActiveRecord::Migration
def change
add_column :users_matches, :last_fetched, :datetime, :default => Time.now
end
end
| Ruby |
class RenameMatchUsers < ActiveRecord::Migration
def change
rename_table :matches_users, :users_matches
end
end
| Ruby |
class RemoveTimeleftFromMatches < ActiveRecord::Migration
def change
remove_column :matches, :timeleft, :timestamp
end
end
| Ruby |
#demo seeds file
User.delete_all
Friend.delete_all
Match.delete_all
UsersMatch.delete_all
WatchedStock.delete_all
#Gabe
gabe = User.new(username: 'gabezilla', firstname: 'Gabe', rank: 1,
email: 'gz@whitehouse.gov', active: Time.now)
gabe.password = '123123password'
gabe.save
#moguls / main friends
mo... | Ruby |
User.delete_all
Friend.delete_all
Match.delete_all
UsersMatch.delete_all
WatchedStock.delete_all
walt = User.new(username: 'wwhite', firstname: 'Walt', rank: 1, email: 'wwhite@gmail.com', active: Time.now)
walt.password = 'wwhite!'
walt.save
jesse = User.new(username: 'jpinkman', firstname: 'Jesse', rank: 2, email: '... | Ruby |
#demo seeds file
User.delete_all
Friend.delete_all
Match.delete_all
UsersMatch.delete_all
WatchedStock.delete_all
#Gabe
gabe = User.new(username: 'gabezilla', firstname: 'Gabe', rank: 1, email: 'gz@whitehouse.gov', active: Time.now)
gabe.password = '123123password'
gabe.save
#moguls / main friends
moguls = [{userna... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
susers = [ # to more dummy users, add more hashes to this array
{username: 'jrock', firstname: "John"},
... | Ruby |
namespace :test do
desc "Test quote.rb"
Rake::TestTask.new(:quote) do |t|
t.libs << "test"
t.pattern = 'test/lib/**/*_test.rb'
t.verbose = true
end
end
| Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
| Ruby |
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
#
# Note: You'll currently still have to de... | Ruby |
require 'rubygems'
require "rexml/document"
require "open-uri"
require "cgi"
require 'digest/md5'
require 'date'
#GLOBALS
CONSUMER_KEY = "FaaKedNASyBQIPujuGtOA"
CONSUMER_SECRET = "VtHRdaHt0otdmwyN6KMprjpGvKzoUReVZtEEhSy0"
ACCESS_KEY = '202832729-aDvW0BoCBjtQ1Ovqg9SMX5wbbaF6Ie6Nn9waugZM'
ACCESS_KEY_SECRET = ... | Ruby |
# sterea.cs.umn.edu
# module load soft/mysql
# module load soft/ruby
require 'rubygems'
require "rexml/document"
require "open-uri"
require "cgi"
require 'digest/md5'
#FROB="72157625041849233-4001e662442717ab-54819442"
API_SECRET = "2a0184a18c05da51"
API_KEY = "c3cc36c3df04978a006e8437fba43b68"
AUTH_TO... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', ... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... | Ruby |
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Be sure to restart your server when you modify this file.
SampleApp::Application.config.session_store :cookie_store, key: '_sample_app_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "ra... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
SampleApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
con... | Ruby |
SampleApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web ... | Ruby |
SampleApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test ... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
SampleApp::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile... | Ruby |
SampleApp::Application.routes.draw do
resources :fridges
resources :fridge_models
resources :users
match '/signin', to: 'users#neweng'
match '/signinfrn', to: 'users#newfrn'
match '/signineng', to: 'users#neweng'
match '/signout', to: 'users#destroy', via: :delete
match '/users/:id/edit', ... | Ruby |
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
| Ruby |
module FacilityTypesHelper
end
| Ruby |
module UsersHelper
def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
current_user = user
end
def sign_out
current_user = nil
cookies.delete(:remember_token)
end
def signed_in?
!current_user.nil?
end
def current_user=(user)
@current_user = user
end
def current_user
@c... | Ruby |
module FridgeModelsHelper
end
| Ruby |
module SessionsHelper
def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
current_user = user
end
def sign_out
current_user = nil
cookies.delete(:remember_token)
end
def signed_in?
!current_user.nil?
end
def current_user=(user)
@current_user = user
end
def current_user
... | Ruby |
module RegionsHelper
end
| Ruby |
module OwnersHelper
end
| Ruby |
module FridgesHelper
end
| Ruby |
module ZonesHelper
end
| Ruby |
module PhrasesHelper
end
| Ruby |
module StaticPagesHelper
end
| Ruby |
module SubdistrictsHelper
end
| Ruby |
module FacilitiesHelper
end
| Ruby |
module DistrictsHelper
end
| Ruby |
class FacilityType < ActiveRecord::Base
attr_accessible :text, :id
end
| Ruby |
class Owner < ActiveRecord::Base
attr_accessible :admin_id, :level, :owner_id
belongs_to :user
end
| Ruby |
class Facility < ActiveRecord::Base
attr_accessible :access_repair, :cba, :cc_delivery, :cc_none, :cc_outreach, :cc_storage, :cylinders, :date_updated, :distance, :elec, :fac_type, :gas, :heavy_clouds, :hi_altitude, :icepack_20_rout, :icepack_20_supp, :icepack_4_rout, :icepack_4_supp, :id, :kero, :lat, :lon, :mode, ... | Ruby |
# @author Oleksiy Khudoliy
# Definitions for name email and passwords
# Make sure they are in correct format
class User < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation, :funds
has_secure_password
before_save { |user| user.email = email.downcase }
before_save :create_... | Ruby |
class Phrase < ActiveRecord::Base
attr_accessible :content, :lang, :num
end
| Ruby |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
else
can :manage, User, :id => user.id
if user.id == 2 || user.id == 1
can :manage, [Subdistrict, Facility, Fridge, Funds]
end
end... | Ruby |
class FridgeModel < ActiveRecord::Base
attr_accessible :elec_to_run, :four_deg_gross_vol, :four_deg_net_vol, :freezing_capacity, :gas_to_run, :intro_date, :item_type, :kero_to_run, :lib_id, :manufacturer_name, :model_name, :patch, :power_sources, :pqs, :prod_price, :refrigerant_gas_type, :retire_date, :twenty_deg_gro... | Ruby |
class Subdistrict < ActiveRecord::Base
attr_accessible :child_bearing, :district_id, :id, :live_births, :name, :population, :under_eight, :under_five
end
| Ruby |
class Funds < ActiveRecord::Base
attr_accessible :amount, :user_id
end
| Ruby |
class Fridge < ActiveRecord::Base
attr_accessible :cfc_free, :comment, :days_eight, :days_two, :dim_h_four, :dim_h_twenty, :dim_l_four, :dim_l_twenty, :dim_w_four, :dim_w_twenty, :equip_id, :fac_code, :food, :fridge_type, :gross_vol_four, :gross_vol_twenty, :installation, :lib_id, :manu_name, :model_name, :net_vol_fo... | Ruby |
class Region < ActiveRecord::Base
attr_accessible :id, :name
has_many :zones
end
| Ruby |
class Zone < ActiveRecord::Base
attr_accessible :id, :name, :region_id
belongs_to :region
has_many :districts
end
| Ruby |
class District < ActiveRecord::Base
attr_accessible :id, :name, :zone_id
has_many :subdistricts
belongs_to :zone
end
| Ruby |
class PhrasesController < ApplicationController
# GET /phrases
# GET /phrases.json
load_and_authorize_resource
def index
@phrases = Phrase.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @phrases }
end
end
# GET /phrases/1
# GET /p... | Ruby |
class FacilitiesController < ApplicationController
# GET /facilities
# GET /facilities.json
load_and_authorize_resource
#skip_before_filter :verify_authenticity_token
def index
@facilities = Facility.all
respond_to do |format|
format.html # index.html.erb
format.json { render js... | Ruby |
class SubdistrictsController < ApplicationController
# GET /subdistricts
# GET /subdistricts.json
load_and_authorize_resource
def index
@subdistricts = Subdistrict.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @subdistricts }
end
end
... | Ruby |
class DistrictsController < ApplicationController
# GET /districts
# GET /districts.json
load_and_authorize_resource
def index
@districts = District.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @districts }
end
end
# GET /districts... | Ruby |
class OwnersController < ApplicationController
# GET /owners
# GET /owners.json
load_and_authorize_resource
# GET /owners/1
# GET /owners/1.json
def show
@owner = Owner.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @owner ... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.