Skip to content

Instantly share code, notes, and snippets.

require File.dirname(__FILE__) + '/../spec_helper'
class Foo
def self.per_page
10
end
end
describe Foo do
should_have_per_page 10
class User < ActiveRecord::Base
acts_as_authentic
attr_accessor :old_password
validates_each :old_password, :on => :update, :if => :crypted_password_changed? do |record, attr, old_password|
unless (old_password.nil? || record.valid_old_password?(old_password))
record.errors.add attr, self.acts_as_authentic_config[:old_password_did_not_match_message]
end
@gumayunov
gumayunov / gist:59853
Created February 7, 2009 11:15
png magic for IE
Element.addMethods({
pngFix: function(el) {
var el = $(el);
if (!(Prototype.Browser.IE && el.match('img') && el.src.include('png'))) return el;
var src = el.src;
var style = {height: el.height, width: el.width}
var filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+src+'",sizingMethod="scale")';
el.src = '/images/pixel.gif';
23:36 gva@saturn:~/avatator>>rake routes | grep -v format
(in /home/gva/avatator)
avatars GET /avatars {:controller=>"avatars", :action=>"index"}
POST /avatars {:controller=>"avatars", :action=>"create"}
new_avatar GET /avatars/new {:controller=>"avatars", :action=>"new"}
edit_avatar GET /avatars/:id/edit {:controller=>"avatars", :action=>"edit"}
avatar GET /avatars/:id {:controller=>"avatars", :action=>"show"}
PUT /avatars/:id {:controller=>"avatars", :action=>"update"}
DELETE /avatars/:id {:controller=>"avatars", :action=>"destroy"}
causes GET /causes
(in /home/gva/bookfeed)
users GET /users {:controller=>"users", :action=>"index"}
POST /users {:controller=>"users", :action=>"create"}
new_user GET /users/new {:controller=>"users", :action=>"new"}
edit_user GET /users/:id/edit {:controller=>"users", :action=>"edit"}
user GET /users/:id {:controller=>"users", :action=>"show"}
PUT /users/:id {:controller=>"users", :action=>"update"}
DELETE /users/:id {:controller=>"users", :action=>"destroy"}
user_reviews GET /users/:user_id/reviews {:controller=>"reviews", :action=>"index"}
user_event
<div class="follow_toggler">
<%= link_to_remote "следить",
:url => user_follows_path(current_user.login, :target=>target_user.login) ,
:method => :post,
:success => "$('unfollow_action').hide();$('follow_action').show();",
:html => { :id => "unfollow_action", :class => "follow", :style => already_follow ? "display:none;" : "" } %>
<%= link_to_remote "не следить",
set :application, "avatator"
set :deploy_to, "/home/gva/#{application}"
set :deploy_via, :remote_cache
set :scm, "git"
set :repository, "git@github.com:gumayunov/avatator.git"
set :git_enable_submodules, 1
#set :gateway, 'unix.sk'
-module(contacts).
-export([resources/0, filters/0, contacts/4, contacts/3]).
-behaviour(controller).
resources() ->
[
#resources{
path = {users, contacts},
@gumayunov
gumayunov / application.rb
Created March 8, 2009 13:37
Authlogic models and controllers snippets
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => 'f581bdec8b45bf4e586ade3d71e25b70'
# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
#!/bin/sh
aptitude -y update
aptitude -y install irb ri rdoc libshadow-ruby1.8 ruby1.8-dev gcc g++ curl
curl -L 'http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz' | tar xvzf -
cd rubygems* && ruby setup.rb --no-ri --no-rdoc
ln -sfv /usr/bin/gem1.8 /usr/bin/gem