Rails, a model based on a custom SQL query

Say I have a table that is a group of many base tables in my database.

I can implement a database view, so I can base the model on it, as I would with a normal "physical" table.
Is it possible to also specify the sql query of the view directly in the model, so without creating the view at all?

+3
ruby-on-rails rails-activerecord


source to share


No one has answered this question yet

Check out similar questions:

1339
How can I rename a database column in Ruby on Rails migrations?
1023
How do I get the current absolute url in Ruby on Rails?
941
Understanding Rails Authentication ID
876
Brief explanation of nil v. Empty v. Blank in Ruby on Rails
351
How do I write a migration to rename an ActiveRecord model and its table in Rails?
344
Can Rails Routing Helpers (i.e. Mymodel_path (model)) be used in models?
306
Ruby on Rails generates model field: type - what are the options for field: type?
303
Rails: include vs .: join
249
Rails: update_attribute vs update_attributes
150
Overriding Rails default_scope



All Articles
Loading...
X
Show
Funny
Dev
Pics