Forum: Ruby on Rails How to rubify this query

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Franz Bettag (Guest)
on 2006-04-20 01:19
Hi guys,

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

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! ;)
This topic is locked and can not be replied to.