I was reworking the 4 days on rails tutorial since I saw an easy way
to use related tables in the find method. So I started to rework the
paginator code and got confused by the different syntax.
This is my code that I was trying fix:
def list_by_category
@item_pages = Paginator.new self, Item.count, 10,
@params[''page'']
** @items = Item.find(:all, :include=> :category,
:order=>''category'')
render_action ''list''
end
This is what the wiki states about using the paginator:
def list
@person_pages = Paginator.new self, Person.count, 10,
@params[''page'']
** @people = Person.find_all nil, ''last_name, first_name'',
@person_pages.current.to_sql
end
my question is about the starred line. Is the second form the older
version? Most of the examples I see have named arguments. I think
the first two arguments are conditions and order_by, but what would be
the third argument in the second form.
Thanks
--
Marlon
"Now watch what you say or they''ll be calling you a radical,
liberal, fanatical, criminal. "
On Sep 9, 2005, at 10:58 AM, Marlon Moyer wrote:> I was reworking the 4 days on rails tutorial since I saw an easy way > to use related tables in the find method. So I started to rework the > paginator code and got confused by the different syntax. > > This is my code that I was trying fix: > > def list_by_category > @item_pages = Paginator.new self, Item.count, 10, @params[''page''] > ** @items = Item.find(:all, :include=> :category, > :order=>''category'') > render_action ''list'' > end > > This is what the wiki states about using the paginator: > > def list > @person_pages = Paginator.new self, Person.count, 10, > @params[''page''] > ** @people = Person.find_all nil, ''last_name, first_name'', > @person_pages.current.to_sql > end > > my question is about the starred line. Is the second form the older > version? Most of the examples I see have named arguments. I think > the first two arguments are conditions and order_by, but what would be > the third argument in the second form. > > Thanks > > -- > MarlonThe find_all form is crusty, old, and deprecated. Use the former. -- Scott Barron Lunchbox Software http://lunchboxsoftware.com http://lunchroom.lunchboxsoftware.com
On 9/9/05, Marlon Moyer <marlon.moyer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I was reworking the 4 days on rails tutorial since I saw an easy way > to use related tables in the find method. So I started to rework the > paginator code and got confused by the different syntax. > > This is my code that I was trying fix: > > def list_by_category > @item_pages = Paginator.new self, Item.count, 10, @params[''page''] > ** @items = Item.find(:all, :include=> :category, :order=>''category'') > render_action ''list'' > end > > This is what the wiki states about using the paginator: > > def list > @person_pages = Paginator.new self, Person.count, 10, @params[''page''] > ** @people = Person.find_all nil, ''last_name, first_name'', > @person_pages.current.to_sql > end > > my question is about the starred line. Is the second form the older > version? Most of the examples I see have named arguments. I think > the first two arguments are conditions and order_by, but what would be > the third argument in the second form.Yes, second form is a depreciated version of the find method. I think the third argument is just a SQL statement that would do some ordering (like ''order by DESC'' or whatever).