hey, this is my situation, and i want to fetch all documents of a certain product, ordered by index_col class Product < ActiveRecord::Base has_and_belongs_to_many :fsdocuments end class Fsdocument < ActiveRecord::Base has_and_belongs_to_many :products end table fsdocuments id int(11) Nee auto_increment filename varchar(250) utf8_general_ci Nee filetype varchar(20) utf8_general_ci Nee filesize bigint(20) Nee 0 name varchar(250) utf8_general_ci Nee description varchar(250) utf8_general_ci Nee lang varchar(10) utf8_general_ci Nee index_col int(11) Nee 0 created_at datetime Nee 0000-00-00 00:00:00 publish tinyint(1) Nee 0 publish_from date Ja 0000-00-00 publish_to date Ja 0000-00-00 created_by int(11) Ja NULL updated_at datetime Nee 0000-00-00 00:00:00 updated_by int(11) Ja NULL deleted_at datetime table fsdocuments_products fsdocument_id int(11) Nee 0 product_id int(11) Nee 0 table products id int(11) Nee auto_increment name_en varchar(100) utf8_general_ci Nee name_fr varchar(100) utf8_general_ci Nee name_nl varchar(100) utf8_general_ci Nee price decimal(10,2) Nee 0.00 publish tinyint(1) Nee 0 publish_from date Ja 0000-00-00 publish_to date Ja 0000-00-00 created_at datetime Nee 0000-00-00 00:00:00 created_by int(11) Ja NULL updated_at datetime Nee 0000-00-00 00:00:00 updated_by int(11) Ja NULL deleted_at datetime when i fetch documents of a certain product i do this: docs = product.fsdocuments now i want those document direct ordered by the "index_col" column, smallest first. so i get 1 2 3 4 5 6 ... Can anyone help me? Thx -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Perhaps this might work: class Product < ActiveRecord::Base has_and_belongs_to_many :fsdocuments, :order => ''index_col'' end On 9/1/06, Nick Brutyn <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > hey, > > this is my situation, and i want to fetch all documents of a certain > product, ordered by index_col > > class Product < ActiveRecord::Base > has_and_belongs_to_many :fsdocuments > end > > class Fsdocument < ActiveRecord::Base > has_and_belongs_to_many :products > end > > table fsdocuments > id int(11) Nee auto_increment > filename varchar(250) utf8_general_ci Nee > filetype varchar(20) utf8_general_ci Nee > filesize bigint(20) Nee 0 > name varchar(250) utf8_general_ci Nee > description varchar(250) utf8_general_ci Nee > lang varchar(10) utf8_general_ci Nee > index_col int(11) Nee 0 > created_at datetime Nee 0000-00-00 00:00:00 > publish tinyint(1) Nee 0 > publish_from date Ja 0000-00-00 > publish_to date Ja 0000-00-00 > created_by int(11) Ja NULL > updated_at datetime Nee 0000-00-00 00:00:00 > updated_by int(11) Ja NULL > deleted_at datetime > > table fsdocuments_products > fsdocument_id int(11) Nee 0 > product_id int(11) Nee 0 > > table products > id int(11) Nee auto_increment > name_en varchar(100) utf8_general_ci Nee > name_fr varchar(100) utf8_general_ci Nee > name_nl varchar(100) utf8_general_ci Nee > price decimal(10,2) Nee 0.00 > publish tinyint(1) Nee 0 > publish_from date Ja 0000-00-00 > publish_to date Ja 0000-00-00 > created_at datetime Nee 0000-00-00 00:00:00 > created_by int(11) Ja NULL > updated_at datetime Nee 0000-00-00 00:00:00 > updated_by int(11) Ja NULL > deleted_at datetime > > when i fetch documents of a certain product i do this: > docs = product.fsdocuments > > now i want those document direct ordered by the "index_col" column, > smallest first. so i get 1 2 3 4 5 6 ... > > Can anyone help me? > > Thx > > > -- > Posted via http://www.ruby-forum.com/. > > > >-- http://www.bdcsoftware.com" - Automotive CRM --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Rafael Szuminski wrote:> Perhaps this might work: > > class Product < ActiveRecord::Base > has_and_belongs_to_many :fsdocuments, :order => ''index_col'' > end > > On 9/1/06, Nick Brutyn <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> class Fsdocument < ActiveRecord::Base >> lang varchar(10) utf8_general_ci Nee >> table fsdocuments_products >> publish_from date Ja 0000-00-00 >> now i want those document direct ordered by the "index_col" column, >> > >> > > > -- > http://www.bdcsoftware.com" - Automotive CRMit works fine thx btw ;) -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---