Skip to content

Instantly share code, notes, and snippets.

View ozgun's full-sized avatar

Ozgun Koyun ozgun

View GitHub Profile
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[] (NoMethodError)
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/console.rb:132:in `print_tag_limit_warnings'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/console.rb:130:in `each'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/console.rb:130:in `print_tag_limit_warnings'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/pretty.rb:232:in `print_summary'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/pretty.rb:27:in `after_features'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:170:in `__send__'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:170:in `send_to_all'
title = "abc"
[1,2].each do |p|
puts title
end
+----+-------------+-------------+-------------------+-------------------+-----------------+----------+
| id | component_a | component_b | component_a_model | component_b_model | connection_type | position |
+----+-------------+-------------+-------------------+-------------------+-----------------+----------+
| 19 | 7 | 3 | 1 | 2 | 1 | NULL |
| 20 | 3 | 7 | 2 | 1 | 1 | NULL |
<style>
ul li:first-child {
color: green;
}
ul li:last-child {
color: red;
}
</style>
<ul>
<li>1</li>
sec1 = "(1) toplama"
sec2 = "(2) çıkarma"
sec3 = "(3) çarpma"
sec4 = "(4) bölme"
puts sec1
puts sec2
puts sec3
puts sec4
@ozgun
ozgun / sinatra-testing-with-sessions.rb
Created May 31, 2011 07:29
sinatra-testing-with-sessions
# Middleware: my_app.rb
class MyApp < Sinatra::Base
enable :sessions
get '/testing' do
puts env['rack.session'].inspect
'testing'
end
end
@ozgun
ozgun / my_app_spec.rb
Created May 31, 2011 08:57
sinatra-testing-with-sessions
it "tests something..." do
sess = {'warden.user.user.key' => [User, User.first.id]}
encoded = [Marshal.dump(sess)].pack("m*")
get "/testing", {}, {'HTTP_COOKIE' => "rack.session=" + encoded}
end
@ozgun
ozgun / action_mailer_ext.rb
Created July 5, 2011 12:33
Monkeypatch ActionMailer's recipients
# config/initializers/action_mailer_ext.rb
# For Rails 2.x
if Rails.env.staging?
class ActionMailer::Base
def recipients(*params)
@recipients = "staging@example.com"
end
<div style="background-color: green; width:500px; height: 500px">Text</div>
@ozgun
ozgun / gist:1141681
Created August 12, 2011 08:13
cucumber - pickle - paths
# eg: I am on the advertisers ad campaign's the ad's edit page
when /^the (.+?) #{capture_model}(?:'s)? #{capture_model}(?:'s)? (.+?) page$/
polymorphic_path [$1.to_sym, model($2), model($3)], :action => $4
# eg: I am on the advertisers the ad campaign's the ad's page
when /^the (.+?) #{capture_model}(?:'s)? #{capture_model}(?:'s)? page$/
polymorphic_path [$1.to_sym, model($2), model($3)]
# eg: I am on the advertisers the ad's edit page
when /^the (.+?) #{capture_model}(?:'s)? (.+?) page$/