This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
has_many :orders | |
has_many :comments | |
def average_rating | |
comments.average(:rating).to_f | |
end | |
validates :name, presence: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
if ARGV.length != 2 | |
puts <<-TEXT | |
Error: wrong number of arguments. Include your app's consumer token and secret: | |
get_twitter_oauth_credentials.rb CONSUMER_TOKEN CONSUMER_SECRET | |
Get your consumer token and secret by registering your app at https://twitter.com/apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# old | |
httpauth = Twitter::HTTPAuth.new(username, password) | |
base = Twitter::Base.new(httpauth) | |
# new | |
oauth = Twitter::OAuth.new(consumer_token, consumer_secret) | |
oauth.authorize_from_access(access_token, access_secret) | |
base = Twitter::Base.new(oauth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Encoding::CompatibilityError: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) | |
GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/mem_cache_store.rb:161:in `gsub' | |
[GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/mem_cache_store.rb:161:in `escape_key' | |
[GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/mem_cache_store.rb:128:in `read_entry' | |
[GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/strategy/local_cache.rb:124:in `read_entry' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in config/initializers/ | |
# prefixed with 'aaa_' so it's loaded first and app configs can be used in the following initializers | |
require 'ostruct' | |
config = File.read(Rails.root.join('config', 'app_config.yml')) | |
unless config.empty? | |
::AppConfig = OpenStruct.new(YAML.load(ERB.new(config).result).with_indifferent_access) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails_env = ENV['RAILS_ENV'] or raise "RAILS_ENV not set" | |
rails_root = ENV['RAILS_ROOT'] or raise "RAILS_ROOT not set" | |
num_workers = rails_env == 'production' ? 1 : 1 | |
num_workers.times do |num| | |
God.watch do |w| | |
w.dir = "#{rails_root}" | |
w.name = "resque-#{num}" | |
w.group = 'resque' | |
w.interval = 30.seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> Booting WEBrick | |
=> Rails 3.0.10 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
Exiting | |
/Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/activesupport-3.0.10/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `failure_app=' for nil:NilClass (NoMethodError) | |
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/devise-1.4.2/lib/devise.rb:405:in `configure_warden!' | |
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/devise-1.4.2/lib/devise/rails/routes.rb:7:in `finalize_with_devise!' | |
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.10/lib/rails/application.rb:128:in `block in reload_routes!' | |
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/activesupport-3.0.10/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2011-09-20T12:06:55+00:00 heroku[api]: Add-on remove cron:daily by manuel.meurer@gmail.com | |
2011-09-20T12:06:55+00:00 heroku[api]: Release v24 created by manuel.meurer@gmail.com | |
2011-09-20T12:06:56+00:00 heroku[web.1]: State changed from up to bouncing | |
2011-09-20T12:06:56+00:00 heroku[web.1]: State changed from bouncing to created | |
2011-09-20T12:06:56+00:00 heroku[web.1]: State changed from created to starting | |
2011-09-20T12:06:57+00:00 heroku[web.1]: Stopping process with SIGTERM | |
2011-09-20T12:06:57+00:00 app[web.1]: >> Stopping ... | |
2011-09-20T12:06:57+00:00 app[web.1]: Exiting | |
2011-09-20T12:06:57+00:00 heroku[web.1]: Process exited | |
2011-09-20T12:06:58+00:00 heroku[web.1]: Starting process with command `bundle exec rails server thin -p 4269` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError: protected method `key_for' called for Activity:Class | |
# Stacktrace | |
lib/ohm_model_template.rb:65:in `method_missing' | |
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:741:in `union_key_for' | |
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:732:in `block (2 levels) in keys' | |
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:723:in `each' | |
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:723:in `block in keys' | |
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:722:in `tap' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23:02:43 (ruby-1.9.2-p290@rails-3.1) ~/apps gem list | grep hoe | |
hoe (2.12.3) | |
23:02:47 (ruby-1.9.2-p290@rails-3.1) ~/apps git clone git://github.com/tenderlove/mechanize.git | |
Initialized empty Git repository in /Users/manuel/apps/mechanize/.git/ | |
remote: Counting objects: 6194, done. | |
remote: Compressing objects: 100% (2105/2105), done. | |
remote: Total 6194 (delta 4143), reused 6083 (delta 4050) | |
Receiving objects: 100% (6194/6194), 961.58 KiB | 318 KiB/s, done. | |
Resolving deltas: 100% (4143/4143), done. | |
23:02:57 (ruby-1.9.2-p290@rails-3.1) ~/apps cd mechanize |