How do you run an ad-hoc query that does not belong in any model? I
thought it was something like ActiveRecord::connection.find(“my
query…”), but I can’t seem to find the documentation on it. I know
I’ve seen it somewhere before, though.
How do you run an ad-hoc query that does not belong in any model? I
thought it was something like ActiveRecord::connection.find(“my
query…”), but I can’t seem to find the documentation on it. I know
I’ve seen it somewhere before, though.
query…"), but I can’t seem to find the documentation on it. I know
This will return an array of hashes with the result set.
–
“Computer games don’t affect kids; I mean if Pac-Man affected us as
kids, we’d all be running around in darkened rooms, munching magic
pills and listening to repetitive electronic music.” – Kristian
Wilson (Nintendo, Inc), 1989
–
“Computer games don’t affect kids; I mean if Pac-Man affected us as
kids, we’d all be running around in darkened rooms, munching magic
pills and listening to repetitive electronic music.” – Kristian
Wilson (Nintendo, Inc), 1989
begin
str_result = str_result[0..-2] # cut off the extra comma
raw_result = ActiveRecord::Base.connection.execute("SELECT id
FROM tasks WHERE parent_id IN (#{str_result})")
str_result = ‘’
raw_result.each do |row|
str_result += “#{row},”
tasks_in_branch += row
end
end until str_result.empty?
tasks_in_branch
end
indeed an acts_as_tree thing
cheers!
Cies Breijs
–
“Computer games don’t affect kids; I mean if Pac-Man affected us as
kids, we’d all be running around in darkened rooms, munching magic
pills and listening to repetitive electronic music.” – Kristian
Wilson (Nintendo, Inc), 1989
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.