interesting bug, ever heard of this one ActiveRecord::MultiparameterAssignmentErrors?
So, on your social networking site the person signing up want’s to expose their birthday so they can get loads of best wishes but is a bit conscious of their age.
>> Person.new("born_on(1i)" => "", "born_on(2i)" => "4", "born_on(3i)" => "25")
ActiveRecord::MultiparameterAssignmentErrors: 1 error(s) on assignment of multiparameter attributes
This has only occured ocassionally, not everytime someone doesn’t want to set their year of birth.
born_on(1i) : year
born_on(2i) : month
born_on(3i) : day
It turns out the assignment gets really confused when it is nil, or at least when the first interger is nil it removes it and sets the first integer it finds to the year, the second to the month and the third…well it sets it to 1, or the first of the month. How annoying. I would have hoped you could validate against assigning incomplete dates, but apparently not.
This breakdown from Thoughtbot demonstrates the process they took to not really solve this problem. Ultimately they used a work around; a before_filter in the controller.
I had sever issues this morning after last night’s upgrade from Ubuntu Jaunty to Koala. Xorg was constantly at 98%, sound was broken, and the whole system was completely unresponsive.
Looking in /boot/grub/menu.lst I noticed the upgrade hadn’t actually added the new kernel at all. So I copied to config for the previous kernel and updated it to the new 2.6.31-14 kernel and on reboot we have sound and Xorg is now playing nicely at about 2% CPU. Panic over.
I saw this about a year ago, it doesn’t have 7 strings….but its the most gorgeous piece of electromological greatness I’ve seen in a while. I guess the only issue is that I wouldn’t want to ruin a work of art by actually playing it.
My favourite independant T-Shirt manufacturer and store, Shirts and Destroy have two new Agoraphobic Nosebleed shirts in stock.
Just a quick quote from their site…
The profits for the items you buy here go to the Bands and Artists we work with. So you really are SUPPORTING these bands and artists when you shop with us. We strictly work with people who’s art we respect and admire. Nothing is sold here that we don’t stand behind artistically 100%. If something offends you were not sorry… this isn’t the mall. Thanks for helping us do our part in supporting independent art and music.
Basically, they rock! Help support the bands you love.
describe FacebookPublisher do
class Facebooker::Service
def post(*args)
return "1"
end
end
it "just should ok" do
Facebooker::Session.create.<some method thingy>
end
end
I wanted to be able to send out a mail from a controller but also validate the incoming args in a clean way. Like so…
class MessagesController < ActionController::Base
def deliver
@message = Message.build(params[:message])
if @message.deliver
redirect_to home_path
else
render :action
end
end
ActionMailer::Base hides the initialize methods in method_missing and most of the time you are calling ActionMailer::Base.deliver_mymail(args). This allows you to specify all of the standard actionmailer settings in Message.build and return a Message object.
class Message < ActionMailer::Base
include Validatable
validates_presence_of :from, :body
def self.build(args = {})
new('default', args)
end
def self.action_mailer_methods
return [
:bcc,
:body,
:cc,
:charset,
:content_type,
:from,
:reply_to,
:headers,
:implicit_parts_order,
:mime_version,
:recipients,
:sent_on,
:subject,
:template
]
end
def default(args)
new_args = args.clone
new_args.each do |k,v|
if self.class.action_mailer_methods.include?(k)
send(k, new_args.delete(k))
end
end
if body.kind_of?(Hash)
@body.merge!(new_args)
end
end
def deliver
if self.valid?
return deliver!
else
return false
end
end
end