Skip to content

Instantly share code, notes, and snippets.

@ryanb
ryanb / index.js.erb
Created December 16, 2011 23:22
Infinite scrolling solution covered in revised episode #114: http://railscasts.com/episodes/114-endless-page-revised
$('#products').append('<%= j render(@products) %>');
<% if @products.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@products) %>');
<% else %>
$('.pagination').remove();
<% end %>
@kinopyo
kinopyo / gist:1205708
Created September 9, 2011 07:53
Snippets for using mysql in ruby
require "mysql"
# more examples:
# http://www.kitebird.com/articles/ruby-mysql.html
hostname = 'localhost'
username = 'yourname'
password = 'password'
database = 'mysql'
port = 3306
@ryanb
ryanb / railscasts_episodes.txt
Created June 29, 2011 21:41
List of all RailsCasts episode names with numbers
001-caching-with-instance-variables
002-dynamic-find-by-methods
003-find-through-association
004-move-find-into-model
005-using-with-scope
006-shortcut-blocks-with-symbol-to-proc
007-all-about-layouts
008-layouts-and-content-for
009-filtering-sensitive-logs
010-refactoring-user-name-part-1
@Marchino
Marchino / rsend.rb
Created June 20, 2011 08:20
Recursive send method for Ruby Objects
# Lets you call object.rsend('method1.method2.method3') instead of object.send('method1').send('method2).send('method3)
class Object
def rsend(method, *params)
method.to_s.split('.').inject(self) { |obj, mth| obj.send(mth.to_sym, *params) }
end
end
ja:
errors:
messages:
not_found: "は見つかりませんでした"
# not_found: "not found"
already_confirmed: "は既に登録済みです"
# already_confirmed: "was already confirmed"
not_locked: "は凍結されていません"
# not_locked: "was not locked"
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@ryanb
ryanb / favorite_gems.md
Created March 4, 2011 17:31
A list of my favorite gems for various tasks.
@dira
dira / application.rb
Created February 10, 2011 02:28
A Rake middleware to specify to OmniAuth where to redirect after successful authentication
# config/application.rb
config.middleware.use 'StoreRedirectTo'
# and make sure you autoload the contents of /lib
<VirtualHost *:80>
ServerName testapp # hosts ファイルに 127.0.0.1 testapp を設定しておく
DocumentRoot "/Users/user/rails/testapp/public"
ErrorLog /Users/user/rails/testapp/log/error.log
CustomLog /Users/user/rails/testapp/log/access.log common
SetEnv GEM_HOME /Users/user/.rvm/gems/ruby-1.8.7-p249 # <-- .rvm 以下の gems フォルダを指定する
SetEnv GEM_PATH /Users/user/.rvm/gems/ruby-1.8.7-p249:/Users/user/.rvm/gems/ruby-1.8.7-p249@global # <-- .rvm 以下の gems フォルダを指定する
RackEnv development # <-- RailsEnv ではない
<Directory "/Users/user/rails/testapp/public">
Order allow,deny
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")