Skip to content

Instantly share code, notes, and snippets.

View bretweinraub's full-sized avatar

Bret Weinraub bretweinraub

View GitHub Profile
rvmuse () {
gemsets=$(grep '@' < <(cd ~/.rvm/gems; find . -maxdepth 1 -type d))
set $gemsets
x=0
while [ $# -gt 0 ];do
((x=$x+1))
echo $x"): "$1 >&2
shift
done
read line
1): ./ruby-1.8.7-p302@seer_sample
2): ./ruby-1.8.7-p302@meteor_catalog
3): ./ruby-1.8.7-p302@medtronic
4): ./ruby-1.8.7-p302@ziya-galeria
5): ./ruby-1.8.7-p302@global
6): ./ruby-1.8.7-p302@alexion
1
Using /home/bweinraub/.rvm/gems/ruby-1.8.7-p302 with gemset seer_sample
/home/bweinraub/.rvm/gems/ruby-1.8.7-p302@adb-demo/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant DashboardWidgetBuilder::Base (NameError)
from /home/bweinraub/.rvm/gems/ruby-1.8.7-p302@adb-demo/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing'
from /home/bweinraub/.rvm/gems/ruby-1.8.7-p302@adb-demo/gems/dashboard-widget-builder-0.2.0/lib/dashboard-widget-builder/google_bar_chart.rb:14
from /home/bweinraub/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /home/bweinraub/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/bweinraub/.rvm/gems/ruby-1.8.7-p302@adb-demo/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /home/bweinraub/.rvm/gems/ruby-1.8.7-p302@adb-demo/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home
def value=(new_value=[])
if new_value.is_a? String
new_value = new_value.split(delimiter)
end
raise ArgumentError("argument to #{current_method} must be an Array").new unless new_value.is_a? Array
@value = new_value
end
ree-1.8.7-2010.02 > class Foo < ActiveRecord::Base
ree-1.8.7-2010.02 ?> end
=> nil
ree-1.8.7-2010.02 > Foo
=> Foo(Table doesn't exist)
ree-1.8.7-2010.02 > Foo.kind_of? ActiveRecord::Base
=> false
class Foo < ActiveRecord::Base
end
class Class
def inherits_from?(klass)
raise ArgumentError.new("argument must be of type Class") unless klass.is_a? Class
if klass == self
true
elsif self.superclass.is_a? Class
self.superclass.inherits_from? klass
ree-1.8.7-2010.02 > reload!
Reloading...
=> true
ree-1.8.7-2010.02 > CalendarEvent.all.collect {|x| x.valid? }
=> [true, false, true, false]
ree-1.8.7-2010.02 > CalendarEvent.all.collect {|x| x.errors.full_messages }
=> [[], [], [], []]
ree-1.8.7-2010.02 > ce = CalendarEvent.all[1]
=> #<CalendarEvent id: 12, created_at: "2010-11-17 06:26:29", updated_at: "2010-11-17 06:26:29", patient_id: 3, start_date: "2010-08-02", end_date: nil, event_type: "actual_infusion", associated_calendar_event_id: 11, months_approved: nil>
ree-1.8.7-2010.02 > ce.errors.full_messages
=> []
ree-1.8.7-2010.02 > ce.valid?
=> false
ree-1.8.7-2010.02 > ce.errors.full_messages
=> ["Associated calendar event the associated event is already associated"]
ree-1.8.7-2010.02 >
cat test/fixtures/hospitals.yml
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
name: E.O.Ü. T.F.
two:
id: 2
bweinraub@localhost:~/dev/aura.git/alexion(alexion)-> rake db:fixtures:load FIXTURES=hospitals
(in /home/bweinraub/dev/aura.git/alexion)
Hospital.create(:name => "E.O.Ü. T.F.")
ActiveRecord::StatementInvalid: PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xdc2e
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".