#rubyonrails - Sat 31 Mar 2007 between 06:14 and 06:18

NY Lost Funds



Palishsection.classroom_id = some_id?
AshimsSELECT * FROM student_entries WHERE student_id IN {SELECT id FROM classroom_table}
is in?
I cant remember
something like that tho
PalishIN! aha!
I knew I was missing *something*
Ashims:)
AHA!
I CONTRIBUTED!
*win*
BigFischHey - I got a problem, can anyone help me out?
Palishthank you!
Ashimsdepends on th eproblem
:)
BigFischYou fine if I link you to a thread where I posted about it?
AshimsI am
I like clicking things
BigFischAshims: Woot, excellent. http://railsforum.com/viewtopic.php?pid=18609#p18609
Ashimsdunno about anyone else-- tho dunno if anyone else is around ;)
BigFischAshims: Haha - well either way thank you very much for taking a look.
Palishokay
ReinHPalish, Ashims: Why are you writing SQL?
Palishactually that SQL isn't exactly what I was looking for
ReinH: Just because I needed some help, and he's a very helpful soul :)
ReinHyou want to find all student entries for all studens in a classroom?
PalishAshims: so student_entries { user_id, section_id } sections { classroom_id }
AshimsReinH: because SQL is great. no good reason not to use it, even if ror provides a noob alternative.
Palishgiven a user_id and a classroom id, determine if a student is in a classroom
ReinHAshims: yes there is a good reason not to use it lol
Palishclassroom has many sections, which has many users
ReinHThe entire point of ActiveRecord is to not have to use it
(SQL)
PalishReinH: well, I'm trying to avoid one SQL lookup per classroom section
chapelAshims: ror isnt a n00b solution, its a smart solution
Ashimslols
the room explodes at me
Palishin activerecord I'd have to do, Sections.find_all_by_classroom_id(id).each do { |sec| if(sec.user_id == uid) return true; }
AshimsI dont know 100% how to use active record-- expecially to do extensive SQL stuff
ReinHPalish: Classroom.sections.find(:all, :include => 'students').map(&:students).include? @student # would be a simple and relatively performant option

Page: 5 12 19 26 33 40 47 54 61 68 75 82 

IrcArchive

NY Lost Funds