June 2008
9 posts
"used it in anger" →
I [Studied] The Lang Not All the Names for the...
max2: Hey all I need help with a very simple issues i'm sure i'm missing somthing very obvious but it is diriving me crazy! http://pastie.org/218157
max2: anyone help me out? http://pastie.org/218157 "You have a nil object when you didn't expect it!" and it should not be nil :/
te: max2: first step i have to suggest is using script/console
te: walk through it and see if you cant find what's happening
max2: i did... but i was looking in dev.log
sebn: max2: @move_out_check_list = @move_out.move_out_check_list.new ?
max2: te: sorry i'm new to rails how would I walk through the code...
max2: sebn: that is the line that is giving me the error..
sebn: max2: shouln't be something like: @move_out_check_list = @move_out.move_out_check_list = MoveOutCheckList.new ?
max2: maybe... note sure... isnt that basicly what I did with; def get_move_out
max2: @move_out = @tenant.move_outs.find(params[:move_out_id])
max2: @move_out_check_list = @move_out.move_out_check_list.new
max2: keep in mind the nest is like this : tenant>move out> move out check list
sebn: max2: anyway, new is a class method
max2: so?
max2: is that good?
sebn: max2: no, unless the @move_out.move_out_check_list value is a class
max2: sorry i'm new what is a class?
sebn: omg
sebn: max2: I think you should read some ruby tutorial :)
max2: i understand a class to be like a function
max2: with subfuction in them..
max2: like: class foo < bar; def method; end
max2: end
sebn: max2: you really should read some ruby documentation :)
max2: i have i just get all the terms mixed up
max2: sebn: how is new a class method, isnted it an activerecord function(method)
sebn: max2: read some ruby documentation
max2: i have read 2 books man
max2: i stuided the lang not all the names for the stuff...
sebn: I can't help you :)
max2: ok thanks anyway.
If you already know .Net languages than you should go for IronRuby only. With...
– To RoR or Not To RoR
Because Everyone in Norway Must Know leethal
il_capitano: the captain knows everything
nice_burger: where are you?
il_capitano: in norway
nice_burger: holy cool deals
nice_burger: you must know leethal
ruby is like a vagina. too wet and it’s a slip n slide, too dry and...
– jbarket on #rubyonrails
Paranthesis Warnings filling production apache... →
railsfactory: hi guys
railsfactory: i need a little help, I have a large rails app and exception handling is hardcoded everywhere.
railsfactory: what I am planning is if I can override rescue method I can log it each time it gets called
railsfactory: the problem i face is rescue is not part of Kernel methods, then how does it gets called
zeroeth: railsfactory: why do you want to log it?
railsfactory: zeroeth, this code is kind of old started and I strongly believe it is slowing up the app, but since it has a large production deployment, I need some numbers to prove my case, so want to show multiple exceptions are raised per request
zeroeth: i see
zeroeth: cant you show that by adding a logger in the rescue itself?
zeroeth: and if your using 'rescue' by itself without specifying what it catches, ill kill you
railsfactory: zeroeth, if i define/overload rescue method and use super will I get my stuff done, seems I am missing some reference
zeroeth: railsfactory: can you not just add a logger into each rescue block
zeroeth: it seems much less nasty
railsfactory: i dont want to add in 100+ locations, thats why I need a cleaner solution
zeroeth: railsfactory: well ask in #ruby-lang as far as any possibility to monkeypatch
railsfactory: thanks
zeroeth: railsfactory: also "find and replace" works well since your just looking to replace "rescue $1" with "rescue $1\nlogger.info("blah")"
zeroeth: it wouldnt be that hard todo in an ide
railsfactory: zeroeth, it is not a pet project :) , and code needs to be commited before it can be tested against staging or test environment
zeroeth: im just sayin, its not 'hard' to replace 100 instances of rescue to add a logger
zeroeth: and its probably faster than monkey patching rescue (if even possible?)
railsfactory: ok I rephrase it, I dont want it to be solved the php way, I wanted if someone can suggest a ruby way
zeroeth: lol
zeroeth: railsfactory: one idea comes to mind.. is tap into Exception classes initializer
railsfactory: hmm, let me check that also, I am now trying to check every class and method on ObjectSpace
railsfactory: zeroeth, I think it is written in C so divng into C, will post back if I suceed
zeroeth: railsfactory: i was afraid of that =0 like i said.. maybe.. exception class's initializer.. but eh
rsl: railsfactory: are you still messing with that rescue thing?
railsfactory: hi rsl, yeah searching, currently inside eval.c
rsl: railsfactory: so you're more comfortable overriding core Ruby functionality at the C level just to avoid search and replace [and doing it the right way] to add logger call inside the rescue block?
railsfactory: I would love to see, if that could be done, see it is ruby, I will never commit a search and replace thing, unless it solves some name refactoring kind of code
rsl: railsfactory: rescue isn't a method it's a ruby keyword. i'd sooner cut off my left arm than think my solution was to override core Ruby keywords if i could do something else.
rsl: i think someone has sold you a bill of goods about how ruby/rails works and monkeypatching everything.
rsl: simple > clever.
railsfactory: rsl, zeroeth , the only reason homo sapiens conquered and thirved, someone somewhere was curious, let there be limits, but we can move the limits thats how we learn and grow
rsl: wow
rsl: again... simple > clever.
railsfactory: maybe I would fail but it helps me be closer with the language i am in love with, knowing the internals, maybe find a 10x optimisation like all new ruby implementaitons are claiming
rsl: railsfactory: also the fact that you don't know enough about Ruby to know that rescue is a keyword but you think you know enough to reimplement it by writing new C for it... beautiful.
Do You Know How to Rails 2.1?
iratik: Why can't I override find_by_sql in rails 2.1 ? Is rails 2.1 not capable of overriding? I'm using a bit of code in config/initializers/activerecord.rb ... allows find_by_sql with include ....what should i do?
iratik: here is the code btw ... http://pastie.caboo.se/207953
iratik: Is there no way to use find_by_sql with more than one table ?
fowlduck: iratik: umm, use joins?
iratik: fowlduck: but activerecord won't load the associated object then
iratik: does anyone know how to rails 2.1 ?
iratik: I need someone who know how to rails 2.1 on this so that it works again http://pastie.caboo.se/207953 .....
fowlduck: Foo.all(:include => :bars)
iratik: So you mean I have to make a standalone rails 1.2.3 app to take serialized request objects from a rails 2.1 app .... process them .. and pass them back to rails 2.1
iratik: that sounds sick
iratik: Is there anyway to call a rails 1.2.3 method from rails 2.1 .. so the rails 2.1 version of the app can talk directly to the rails 1.2.3 version of the app?