Skip to content

Instantly share code, notes, and snippets.

View linojon's full-sized avatar

Jonathan Linowes linojon

View GitHub Profile
njero - http://neverlet.be
sutto - http://blog.ninjahideout.com
zapnap - http://blog.zerosum.org
tpope - http://tpope.net
reinh - http://reinh.com
bryanl - http://smartic.us
linoj - http://www.vaporbase.com
def menu_item( name, url_options={}, section_url=nil, &block)
#debugger
current = current_page?(url_options)
content = content_tag :li, :class => (current ? 'current' : nil) do
link_to(name, url_options) +
(block.nil? ? '' : capture(&block))
end
block.nil? ? concat(content, binding) : concat(content, block.binding)
end
map.resources :accounts, :conditions => { :subdomain => 'www'}
map.resource :account, :ony => [:show],
:member => {
:activate => :get,
:change_level => :get,
:update_level => :put,
:confirm_close => :get,
:close => :delete
}
# account
has_many :projects
# project
belongs_to :phase
# phase
# :name => 'open'
# whats the right way to do this? doesnt work:
===========================
local development machine
===========================
$ script/console production
Loading production environment (Rails 2.3.2)
>> h = Nokogiri::HTML( open("http://www.google.com") )
=> <!DOCTYPE html>
<html>
<head>
## steps file
def fill_in_upload( resource, field, value )
# adds a resource in the name
# when you specify "#{fieldname} upload: files/foo.ext" we convert value into an upload (assumes no field named foo_upload)
# when field name is dotted, assumes its an association using *_attributes (eg user.email => [user_attributes][email])
# otherwise works like fills_in
# when fills_in fails, tries it as a
# - radio select
# - dropdown select (TODO)
## app/controllers/application_controller.rb
helper :all
protect_from_forgery
include Authentication
## lib/authentication.rb
module Authentication
filter_parameter_logging :password, :password_confirmation
before_filter :newer_browser_required
def newer_browser_required
# ref http://pastie.org/203799
# reject MSIE 5.0 and MSIE 6.0
browser_access_denied if request.user_agent =~ /msie\s+[5,6]\.\d+/i
end
def browser_access_denied
## gem file bogus.rb
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
# Bogus Gateway
class BogusGateway < Gateway
AUTHORIZATION = '53433'
SUCCESS_MESSAGE = "Bogus Gateway: Forced success"
...
# This is an extension to ActiveMerchant to make the CIM gateway look a little more like the other gateways that
# support recurring billing. I wrote this code for the SaaS Rails Kit (http://railskits.com/saas), so if you are
# looking for a billing solution for your Rails application, feel free to check it out. :)
require 'digest/sha1'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class AuthorizeNetCimGateway < Gateway