Friday, May 14, 2010
Double Callbacks
I wasted an entire day because i placed a backup file of a model in the app/models/ directory. (I think I made a similar mistake before :P ) And in that backup, there are callbacks so even when i removed the callbacks in the actual model file, the callback was still being called. Maybe I was creeped out so it took me the entire day to figure it out. Remember, rails loads the entire directory! What a noob mistake.
Thursday, May 6, 2010
Weird submodule story
One day i came upon this error when i tried committing a plugin using git:
fatal: Path 'vendor/plugins/whatever/ChangeLog' is in submodule 'vendor/plugins/whatever'
(I cloned the whatever plugin into my vendors/plugin folder by the way)
I had no .gitmodule file and there are no references to whatever plugin in my .git/config. I also removed all the .git folders in the whatever plugin.
Anyway, if you encounter this too, and you don't want to add a submodule use this:
git rm --cached vendor/plugins/whatever
Strip blank strings and nil elements from Ruby Array
array_with_blanks_and_nils = ["a", '', nil]
array_with_blanks_and_nils.compact.reject(&:blank?) #=> ["a"]
array_with_blanks_and_nils.compact.reject(&:blank?) #=> ["a"]
Monday, May 3, 2010
Send Mail with Pony
Use Pony to send mail in one line:
Pony.mail(:to => 'you@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Hello there.')
Pony.mail(:to => 'you@example.com', :cc => 'him@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Howsit!')
Pony.mail(:to => 'you@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Hello there.')
Pony.mail(:to => 'you@example.com', :cc => 'him@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Howsit!')
Subscribe to:
Posts (Atom)
