Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Ship it!

Ricardo Shiota Yasuda shadowmaru

:shipit:
Ship it!
View GitHub Profile
@shadowmaru
shadowmaru / gist:8796
Created Sep 4, 2008
Layout file example
View gist:8796
app/views/layouts/application.html.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><%= @title || "Título" %></title>
<%= stylesheet_link_tag 'site' %>
<%= javascript_include_tag 'application', 'prototype', 'effects' %>
View create_authorizenet_gateway.rb
class CreateAuthorizenetGateway < ActiveRecord::Migration
def self.up
login = GatewayOption.create(:name => "login",
:description => "Your Authorize.Net API Login ID")
password = GatewayOption.create(:name => "password",
:description => "Your Authorize.Net Transaction Key.")
test = GatewayOption.create(:name => "test",
:description => "If true, perform transactions against the test server. Otherwise, perform transactions against the production server.")
gateway = Gateway.create(:name => "Authorize.net",
View production.log
Processing OrdersController#fire (for xxx.xxx.xxx.xxx at 2008-11-19 09:06:43) [PUT]
Session ID: BAh7CjoOcmV0dXJuX3RvMDoMY3NyZl9pZCIlZmI0NGUxYzQxMTY0NWRhNDBh
YWVlZmM2ZmNhYTY3NzI6DHVzZXJfaWRpBiIKZmxhc2hJQzonQWN0aW9uQ29u
dHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7ADoNb3JkZXJf
aWQw--8ec59532c83eef92f2e1cdaada63121ecce91fdc
Parameters: {"action"=>"fire", "_method"=>"put", "authenticity_token"=>"f26f6ddcc8db30ba2a504002fb01883e1bfeb4b4", "id"=>"685019094", "e"=>"capture", "controller"=>"admin/orders"}
Gateway Error ...
Redirected to http://xxxxx.com/admin/orders
Completed in 0.65447 (1 reqs/sec) | DB: 0.04395 (6%) | 302 Found [http://xxxxxx.com/admin/orders/685019094/fire?e=capture]
View useful_plugins.txt
Useful Rails plugins
jrails
paperclip
resource_controller
restful-authentication
restful-authorization
shoulda
tlsmail
ultrasphinx
View calendar.html.erb
<% calendar :year => 2009, :month => 1, :events => @events, :field => :happens_on do |date, events| %>
<% for event in events %>
<%= link_to event.name, event_path(event) %>
<% end %>
<% end %>
View controller_for_image_model.rb
class ImageModelsController < ApplicationController
before_filter :find_image_model, :only => [:update]
def update
if @image_model.update_attributes(params[:image_model])
@image_model.image.reprocess!
end
end
protected
View gist:146425
Letícia: Olá Ricardo, em que posso ajudar ?
Ricardo: Olá, fiz um pedido no dia 2/7 e até hoje ele está em ´análise´
Ricardo: O número do pedido é XXXXX
Letícia : Sr.,infelizmente houve um erro no sistema,
sob o qual seu pedido se encontra. Pedimos
desculpas pelo transtorno, mas caso ainda
deseje adquirir este produto,pedimos para
View tm-migration.sh
#
# Generates the migration and opens it in TextMate
#
# ex.:
# mig AddNewColumnToModel new_column:integer
#
function mig {
mate `script/generate migration $@ | tail -n1 | sed 's/.*create //'`
}
View gist:173503
class PageSweeper < ActionController::Caching::Sweeper
observe Page
def after_save(page)
clear_page_cache
end
def after_destroy(page)
clear_page_cache
end
View gist:173506
module ActionController
module Caching
class Sweeper
def sweep_directory(dirs)
dirs.each do |dir|
cache_dir = RAILS_ROOT + "/public/#{dir}"
FileUtils.rm_r(Dir.glob(cache_dir+"/*")) rescue Errno::ENOENT
RAILS_DEFAULT_LOGGER.info("Cache directory '#{cache_dir}' fully swept.")