Skip to content

Instantly share code, notes, and snippets.

View gerhard's full-sized avatar

Gerhard Lazu gerhard

View GitHub Profile
>> my_hash = {"1" => {"user_id" => "23233" }}
=> {"1"=>{"user_id"=>"23233"}}
>> my_hash.keys
=> ["1"]
def create
@company = Company.new(params[:company])
begin
if @company.save
redirect_to_index("Company was successfully created")
else
render :action => "new"
end
rescue ActiveRecord::RecordInvalid
render :action => "new"
apeiros_: send accepts a method name. for x.foo = "bar", the method name is 'foo='
apeiros_: oh boy. macgerhard, x.send(method, *args)
apeiros_: your method is 'attrname='
apeiros_: your args is the value you want to assign
apeiros_: and there IS NO = after send. makes no sense.
RewriteCond %{REQUEST_METHOD} !^(GET|PUT|POST|DELETE|HEAD)$
RewriteRule .* - [F,L]
class PurchaseOrder < ActiveRecord::Base
has_one :address_linking, :as => :address_linkable, :dependent => :destroy
has_one :address, :through => :address_linking
end
class AddressLinking < ActiveRecord::Base
belongs_to :address
belongs_to :address_linkable, :polymorphic => true
end
# each approach
locations = []
stocks.each {|stock| locations << stock.location}
return locations
# refactored with inject
stocks.inject([]) {|locations, stock| locations << stock.location}
# GO RUDY! http://gist.github.com/42552
<% @organisations_by_letter.each do |letter| -%>
<li><%= link_to_unless(letter == params[:id], letter, organisation_url(letter)) do |name|
link_to(name, organisation_url(letter), :class => "active")
end %></li>
<% end -%>
gerhardlazu@dino:aspire-branched (master) $ /opt/local/libexec/git-core/git-for-each-ref refs/remotes/tags0e23924cc26560b2ef36705b0d0bbecd83d8fe98 commit refs/remotes/tags/aardvaark
174a98d8bcf144ce3caa128fd093c81603cd8032 commit refs/remotes/tags/badger
4196b456595ed76f2f0d74fab5a0b9a2e66377fc commit refs/remotes/tags/coelacanth
05fe5700ad3e20d37c7f7651d6e462a184b42538 commit refs/remotes/tags/coelacanth2
ce40b9450ad9f17149b9a411c91fbd3a6a317f15 commit refs/remotes/tags/coelacanth3
6e15809cf3c55a3745e79a11725d15aff77cc24b commit refs/remotes/tags/dik-dik
53b61cf43cb7a1e1dca93d19dbe54c9d66ec3f5d commit refs/remotes/tags/earthworm
a1c5e8df37aca6b214e44a73732aebe25e1da950 commit refs/remotes/tags/earthworm2
71a4f980afe86aff008e004fc195594b7e1fed87 commit refs/remotes/tags/galapagos
b91a71dc39ec604c51907ce1a6170bc49fb0f2ad commit refs/remotes/tags/hummingbird
### FETCHES REMOTE CONTENT, DOESN'T MERGE
gerhardlazu@dino:aspire (master) $ git fetch github
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
From git@github.com:jgp/aspire
7ed735f..2773252 master -> github/master
* [new branch] springbok2 -> github/springbok2
### CREATED A NEW BRANCH TO TRACK THE REMOTE ONE
git filter-branch --env-filter '
n=$GIT_AUTHOR_NAME
m=$GIT_AUTHOR_EMAIL
case ${GIT_AUTHOR_NAME} in
gerhardl) n="Gerhard Lazu" ; m="mail@gerhardlazu.com" ;;
esac
export GIT_AUTHOR_NAME=$n
export GIT_AUTHOR_EMAIL=$m
export GIT_COMMITTER_NAME=$n
export GIT_COMMITTER_EMAIL=$m