some of my favorite ruby gem names
Things I learned the hard way XIVII
$("#item_id > a")
$("#item_id > ul > li > a'")
Snow Leopard 10.6 Rails/Passenger
*** Exception RangeError in PhusionPassenger::Railz::ApplicationSpawner (integer 4294967294 too big to convert to `int') (process 1097):
Javascript Exceptions - testing for true - When is undefined actually undefined?
if (unreferencedVariableName) { alert('Impossible! an unreferenced variable cannot return true. In fact it cannot return at all!'); }
/* is as true as the unescapable pain and suffering of being an alive human being */ if (typeof(cowBoySuckMonkey) === 'undefined') { console.log('suck it!') } /* these are false - no if-fu for you! */ if (typeof(cowBoySuckMonkeee) != 'undefined') { console.log('suck it again!') } if (!typeof(cowBoySuckMonkeee)) { console.log('suck it for real!') } /* 'undefined is something I guess - just not what I wanted to test against */ if (typeof(cowBoySuckMonke)) { console.log('suck it nut gobbler!') } var cowboySuckMonkay = ''; if (typeof(cowboySuckMonkay) != 'undefined') { console.log('suck it empty string!') } /* no joy */ if (typeof(cowboySuckMonkay)) { console.log('suck it empty string, part duex!') } /* well, I guess an empty string is false - CaulkGobblin! */ if (cowboySuckMonkay) { console.log('suck it empty string, you still not true!') } if (cowboySuckMonkay == '') { console.log('suck it empty string, now you true!') }
comparison of Fixnum with String failed
Where the error occured
Rails 2.1.2 / bundle_fu / Javascript fileWhy the fu…?
A javascript files that ends with a line commented out. -1 is being compared to an empty string.Fix
Add a blank line at the end of the Javscript file(s) that end with commented lines.snipdbits
// both are the same if ( 0 == 0 && 0 === 0) alert('0 is equal to 0, and 0 is the same value and object type as 0'); if ( 0 == 0 && 0 === 0) alert('0 is equal to 0, and 0 is the same value and object type as 0');
designation agitator
My favorite class name when styling a page is ‘padahoe’. If anyone ever asks what it stands for I’ll tell them “pad a horizontally oriented element”. Lies, damn lies, statistics.
When I commit to git I tend to flavor my commit messages with humorous snark, usually related to how something in the application is deviously circumventing my attempts to enforce my authority. My logic is shot through with regression insurgents.
jrails link_to_function hackaway
<%= link_to_function( "insert it", :id => 'foo') do |page|
partial = escape_javascript(render :partial => "my_partial", :object => Object.new)
page << "$('#my_div').append('#{partial}')"
end %>Sweetness.
happens not adderall in the business of
all lies – less pain to just use current_user and accept the inaccurate naming of the models intent in the instance variable.
fuckin’ fuck, man.
I use restful_acl gem and the restful_auth plugin – restful_auth has generators so that when you create the restful authorization model it will take your class name and fill in the places where it needs to go I have an account model instead of a user model so it filled in all of the instance variables for authenticated user methods with current_account. The restful_acl gem is hardcoded to the current_user instance variable. So I opened the module and method in a file in /lib called restful_acl_controller_hacks.rb so I could alias current_account to current_user.
module RestfulAclController
module ClassMethods
def has_permission?
alias current_user current_account
end
end
end
Then I required the file in the application controller:
require 'restful_acl_controller_hacks'Now has_permission? works and my specs pass and all is right with the world. For about 2 minutes until I smash into another coding wall due to my lack of experience and inability to remember most things of importance related to OOP.
stupid arguments
## controller code def find_my_fucking_shit @my_class = MyClass.special_method_in_model(params[:shit], params[:not]) end ## controller spec # This will fail and you will want to punch a bitch in the nose because you spent two fucking days # figuring you were just really goddamn stupid (which may be true) because it should work but it doesn't it "should find shit" do MyClass.should_receive(:special_method_in_model).with({:shit => 'will', :not => 'work'}).and_return(mock_my_shit) get 'find_my_fucking_shit', :shit => 'will', :not => 'work' end # This will pass it "should find shit" do MyClass.should_receive(:special_method_in_model).with('will', 'work').and_return(mock_my_shit) get 'find_my_fucking_shit', :shit => 'will', :not => 'work' end
