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 MembersController < ApplicationController | |
# GET /members | |
# GET /members.json | |
skip_filter :authenticate, :only => [:new, :create, :index] | |
before_filter :authenticate_self_or_admin, :only => [:edit, :destroy] | |
def authenticate_self_or_admin | |
m = Member.find(session[:member_id]) | |
if m.role == 'Admin' |
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 | |
protect_from_forgery | |
before_filter :authenticate, :except => [:login, :notify_member] | |
def authenticate | |
if session[:member_id].nil? | |
flash[:alert] = 'You need to login first.' | |
redirect_to :controller => 'admin', :action => 'login' | |
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
<ul id="navbar"> | |
<li><a href="/members/">Members</a></li> | |
<li><a href="/events/">Events</a></li> | |
<li><a href="/libraries/">Libraries</a></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
def authenticate_self_or_admin | |
m = Member.find(session[:member_id]) | |
if m.role == 'Admin' | |
elsif session[:member_id].nil? | |
flash[:alert] = 'You need to login first.' | |
redirect_to(:controller => 'admin', :action => 'login') | |
elsif session[:member_id].to_s != params[:id] |
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
def login | |
if request.post? | |
user = User.find_by_email(params[:email]) | |
if ! user.nil? && user.password == params[:password] | |
session[:user_id] = user.id | |
progress_redirect | |
else | |
redirect_to(:back, :alert => "Invalid Email/Password.") | |
end | |
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
<iframe src="http://player.vimeo.com/video/65822130" width="500" height="889" frameborder="0" | |
webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> | |
<p><a href="http://vimeo.com/65822130">First Apartment</a></p> |
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
def whip2 | |
if self.age < 28 | |
self.whip * 0.95 | |
else | |
self.whip * 1.05 | |
end | |
end | |
def whip3 | |
if self.age < 28 |
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 Pitcher < ActiveRecord::Base | |
attr_accessible :age, :name, :whip | |
alias :whip_1 :whip | |
(2..7).each do |num| | |
define_method("whip_#{num}") do | |
if self.age < 28 | |
eval("self.whip_#{num-1}") * 0.95 | |
else | |
eval("self.whip_#{num-1}") * 1.05 |
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
(2..7).each do |num| | |
define_method("whip_#{num}") do | |
if ((self.age + num) < 30) | |
(eval("self.whip_#{num-1}") * 0.95) | |
else | |
(eval("self.whip_#{num-1}") * 1.05) | |
end | |
end | |
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
def index | |
sort_ruby_tweets($client.get_tweets("adgilfillan")) | |
end | |
def $client.get_tweets(user) | |
options = {:count => 200, :include_rts => true, :exclude_replies => true} | |
user_timeline(user, options) | |
end | |
OlderNewer