How to rubify this query


#1

Hi guys,

i spent about 5 hours now of finding out how to rubify/railify this
query!
Maybe someone of you can help me :wink:

class Menu < ActiveRecord::Base
validates_uniqueness_of :handle
validates_presence_of :name, :sequence, :accesslevel, :defaultpage,
:handle

belongs_to :cmodule
belongs_to :creator, :class_name => ‘User’, :foreign_key =>
‘created_by’
belongs_to :updater, :class_name => ‘User’, :foreign_key =>
‘updated_by’
end

Now this is my query:
@menu = Menu.find_by_sql “SELECT self.* FROM menus self, menus remote
WHERE self.parent_id = remote.id
AND remote.handle = ‘#{parent}’
AND self.accesslevel <=
#{session[:user][:accesslevel]}
ORDER BY self.sequence”

Any ideas? thanks! :wink: