Thanks Jonathan for the example. I had been using an AR model for my
non-rails table. The piece I was missing was setting the table name!

So for others this is what I did

class Whatever < AR
self.establish_connection :whatever (non-rails DB defined in .yml)
self.set_table 'name of non-rails table'
end

whatever_controller.rb
def index
@rows = Whatever.find(:all) (find_by_sql works too)
end

now you can do AR stuff with @rows - like loop on it and call row.name

Hope that helps someone else!

Thanks.


On May 19, 1:18 pm, Jonathan Rochkind <[email protected]> wrote:
> Jonathan Rochkind wrote:
> > An AR model for a particular table, as you can see you can even use AR
> > associations (to other tables within the same db! Trying to make
> > associations cross-db tends not to work):
> >http://umlaut.rubyforge.org/svn/trunk/app/models/sfx_db/object.rb
>
> Heh, I also see reviewing old code I haven't looked at for a while, that
> naming one of my own classes "Object" probably wasn't a great idea, even
> if it is in a module namespace. Don't copy that part. :)
> --
> Posted viahttp://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to