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
# SANDBOX EXAMPLE | |
#=========================================================================================================== | |
# RAKE FILE START | |
#=========================================================================================================== | |
desc "Perform Calculations" | |
task :calc => :environment do | |
# Category |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<comparison> | |
<team> | |
<name>Florida</name> | |
<tsrs type="float">111.423</tsrs> | |
<offensive_statistics> | |
<raw_stats> | |
<total_offense type="float">445.07</total_offense> | |
<rushing_offense type="float">231.14</rushing_offense> | |
<passing_offense type="float">213.93</passing_offense> |
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
named_scope :compiled_this_week, lambda { { :conditions => ['created_at > ? and created_at < ?', Time.now.beginning_of_week, Time.now.end_of_week] } } | |
# I have a series of constants that use the following format: | |
OFFENSE_RUSHING = [:rank, :team_id, :games, :carries, :net, :avg, :tds, :ydspg, :wins, :losses, :ties] | |
# These constants are called in the method below | |
# url, name, deep only apply to my scraper class and is used for parsing so it's not an issue here | |
# If no data is found for the current week, new data is created - this works fine |
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
# Set up email server using Gmail | |
ActionMailer::Base.delivery_method = :smtp | |
ActionMailer::Base.smtp_settings = { | |
:enable_starttls_auto => :true, | |
:address => "smtp.gmail.com", | |
:port => 587, | |
:domain => "yourdomain.com" , | |
:authentication => :plain, | |
:user_name => "your_username" , |
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
<html> | |
<head> | |
<title>Contact Message</title> | |
</head> | |
<body> | |
<h2>Contact Email Received</h2> | |
<ul> | |
<li>From: <%= @message.name %></li> | |
<li>Company: <%= @message.company %></li> | |
<li>Phone: <%= @message.phone %></li> |
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
# Be sure to restart your server when you modify this file | |
# Specifies gem version of Rails to use when vendor/rails is not present | |
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION | |
# Bootstrap the Rails environment, frameworks, and default configuration | |
require File.join(File.dirname(__FILE__), 'boot') | |
Rails::Initializer.run do |config| | |
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 CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table "users", :force => true do |t| | |
t.string :login, :email, :remember_token, :first_name, :last_name, :limit => 100 | |
t.boolean :admin, :super | |
t.string :crypted_password, :limit => 40 | |
t.string :password_reset_code, :limit => 40 | |
t.string :salt, :limit => 40 | |
t.string :activation_code, :limit => 40 | |
t.datetime :remember_token_expires_at, :activated_at, :deleted_at, :created_at, :updated_at |
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 ApplicationController < ActionController::Base | |
helper :all # include all helpers, all the time | |
protect_from_forgery | |
include AuthenticatedSystem | |
private | |
# Defining a function called authorize which will make sure that any pages we don't want accessible |
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 UsersController < ApplicationController | |
before_filter :find_user, :only => [:suspend, :unsuspend, :destroy, :purge] | |
before_filter :login_required, :except => [:new, :create, :activate, :change_password, :forgot_password, :reset_password] | |
before_filter :authorize, :except => [:new, :create, :activate, :change_password, :forgot_password, :reset_password] | |
def index | |
@users = User.find(:all) | |
respond_to do |format| |
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 'digest/sha1' | |
class User < ActiveRecord::Base | |
# Virtual attribute for the unencrypted password | |
attr_accessor :password | |
validates_presence_of :login, :email, :first_name, :last_name | |
validates_presence_of :password, :if => :password_required? | |
validates_presence_of :password_confirmation, :if => :password_required? | |
validates_length_of :password, :within => 4..40, :if => :password_required? |
OlderNewer