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
# auth controller | |
def login | |
... | |
rescue Exception=> ex | |
logger.error ex.message | |
logger.info ex.backtrace.join("\n") | |
clear_session | |
flash[:warning] = "Incorrect login or password." | |
# in coverage and debugger, this line is not being called!?! | |
render :action => 'login', :layout=> 'simple' |
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
def test_recalc_with_formula_error | |
Parameter.any_instance.stubs(:default_formula => "=whatever") | |
get :recalc, :id => @task | |
#... | |
ensure | |
Parameter.any_instance.unstub(:default_formula) | |
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
FooController callbacks: | |
index: | |
get_foos | |
new: | |
get_foo | |
set_foo_defaults | |
check_bar_rights | |
create: | |
get_foo | |
check_bar_rights |
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
# The right way | |
# | |
#---------------------------------------------------------------- | |
# Production database Real data | |
#---------------------------------------------------------------- | |
# | |
development: | |
... |
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
# attempt to use underscored attributes | |
# e.g. labware_item_id would still return labwareitemid | |
def method_missing(method, *args, &block) | |
super method, args, block | |
rescue | |
if method.to_s.include?('_') | |
m = method.to_s | |
m = m.gsub('_', '').downcase | |
puts "#{method} is not present, trying #{m}" | |
return self.send m |
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
It's a simple idea, after enthusing the crowd at BACON with the | |
Text-to-music concept, a chance to try it out, en masse, and see | |
what happens. | |
So, to join in you need: | |
* to be at BACON | |
* a Linux or Mac laptop | |
* a clone of the repo at www.github.com/ajfaraday/Text-to-music | |
* read the readme, set it up |
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
# any idea what's going on here? | |
>> () | |
=> nil | |
>> (true) | |
=> true | |
>> ('string') | |
=> 'string' | |
>> (true,false) | |
SyntaxError: compile error |
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 Event < ActiveRecord | |
has_many :charges do | |
def self.total | |
self.collect{|charge|charge.total}.sum | |
end | |
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
hash_1 = {:string => 'string', :hash => {:property_A => 'a'}} | |
hash_2 = {:hash => {:property_B => 'b'}} | |
hash_1.merge(hash_2) | |
# => {:string=>"string", :hash=>{:property_B=>"b"}} | |
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
# server log | |
Started POST "/dashboards/33/fill_portlet_form" for 127.0.0.1 at 2013-07-03 11:12:04 +0100 | |
[ FATAL: 11:12:04.143] | |
LoadError (Expected /home/ajfaraday/biorails/develop_5.0/app/controllers/admin/dashboards_controller.rb to define DashboardsController): | |
# routing file | |
scope :module => "admin" do | |
resources :dashboards do |