I think that is the same situation... If model do not have a default order,
sort by id (on list) or by label (form_ui :select).

I don't know how I check it.

2009/6/25 Kenny Ortmann <[email protected]>

> I dont think that it should remove it.  Active Scaffold is meant to do
> things for you by default.  That is why you can override almost everything
> that it does for you.  If you don't want it to order them alphabetically
> then override it
>
> ~Kenny
>
>
> On Thu, Jun 25, 2009 at 12:28 PM, G. Sobrinho 
> <[email protected]>wrote:
>
>> Ok, I will use this solution, thanks.
>>
>> Another issue with scope: When I use associated models and set that
>> form_ui with :select, the ActiveScaffold force this results to sort
>> alphabeticaly. I find it on
>> vendor/plugins/active_scaffold/lib/helpers/association_helpers.rb:
>>
>> available_records.sort{|a,b| a.to_label <=> b.to_label}.collect { |model|
>> [ model.to_label, model.id ] }
>>
>> It's forcing the sort, i removed it. I think the ActiveScaffold needs to
>> remove that
>>
>> 2009/6/25 Sergio Cambra .:: entreCables S.L. ::. <[email protected]>
>>
>>
>>> On Jueves, 25 de Junio de 2009 08:06:59 G. Sobrinho escribió:
>>> > / Sorry, i sended without the second part...
>>> >
>>> > So, the database sort by id none is specified. The ActiveScaffold
>>> doesnt
>>> > need to add the order clause.
>>>
>>> No, it depends on database engine, I have got different results sometimes
>>> with
>>> queries without order. Databases usually returns records in disk order
>>> when
>>> query has no order clause, and with partitioned tables the default order
>>> is
>>> random (for example in mysql cluster all tables are partitioned). Oracle
>>> documentation says "If you do not include an ORDER BY clause then the
>>> order of
>>> the result set rows will be unpredictable (random or quasi random)." So
>>> IMO
>>> it's good adding order by id when there is no order (not adding it could
>>> break
>>> pagination) if you can disable it (you can with
>>> config.columns[:id].sort=false)
>>>
>>> >
>>> > If I explicit a sort column (clicking on header of column or setting in
>>> > controller), the AS needs to add the clause. Othewise, no.
>>> >
>>> > I think this is the best form.
>>> >
>>> > 2009/6/25 G. Sobrinho <[email protected]>
>>> >
>>> > > But the databases, by default, sort by id if nothing is specified.
>>> So,
>>> > > the ActiveScaffold dont need to set it which avoid the defaut_scope
>>> in my
>>> > > situation.
>>> > >
>>> > >
>>> > > 2009/6/24 <[email protected]>
>>> > >
>>> > >> Yes sort of?
>>> > >>
>>> > >> See active scaffold adds sort by id by default unless you tell it to
>>> do
>>> > >> differently.
>>> > >> You told your model to have some default scopes as well. The order
>>> in
>>> > >> which these are added must be active scaffold scope first,
>>> default_scope
>>> > >> second, because the id scope shows up higher in priority.
>>> > >>
>>> > >> I believe you can turn off the sorting by id,
>>> > >>
>>> > >> config.columns[:id].sort = false
>>> > >>
>>> > >> or something like that, it might be config.list.columns[:id].sort =
>>> > >> false
>>> > >>
>>> > >> ~kenny
>>> > >>
>>> > >> Sent from my Verizon Wireless BlackBerry
>>> > >>
>>> > >> ------------------------------
>>> > >> *From*: "G. Sobrinho"
>>> > >> *Date*: Wed, 24 Jun 2009 23:39:37 -0300
>>> > >> *To*: <[email protected]>
>>> > >> *Subject*: Re: Order of records with default_scope
>>> > >> Yes, the id ASC are added because ActiveScaffold tryed to sort by
>>> it.
>>> > >>
>>> > >> But by default, in theory, the Active Scaffold can't sort the
>>> records by
>>> > >> any fields except I explicited it. Not?
>>> > >>
>>> > >> 2009/6/24 <[email protected]>
>>> > >>
>>> > >>> I belive active scaffold tries to order by I'd by default so it is
>>> > >>> adding it.
>>> > >>>
>>> > >>> I would use the config sort that active scaffold provides for you,
>>> look
>>> > >>> at the list config wiki page for examples
>>> > >>>
>>> > >>> Sent from my Verizon Wireless BlackBerry
>>> > >>>
>>> > >>> ------------------------------
>>> > >>> *From*: "G. Sobrinho"
>>> > >>> *Date*: Wed, 24 Jun 2009 19:07:39 -0300
>>> > >>> *To*: activescaffold<[email protected]>
>>> > >>> *Subject*: Order of records with default_scope
>>> > >>> Hello,
>>> > >>>
>>> > >>> I'm using default_scope on some models to sort the records but the
>>> AS
>>> > >>> have a issue with that.
>>> > >>>
>>> > >>> For example, i have a model named Page:
>>> > >>>
>>> > >>> class Page < ActiveRecord::Base
>>> > >>>   default_scope :joins => :category, :order => 'categories.order
>>> ASC,
>>> > >>> pages.order ASC'
>>> > >>> end
>>> > >>>
>>> > >>>
>>> > >>> When I access the list, the SQL generated is (order part): "ORDER
>>> BY
>>> > >>> pages.id ASC, categories.order ASC, pages.order ASC"
>>> > >>> But I don't setted the AS to sort by id. Well, this doesn't work.
>>> > >>>
>>> > >>> It's a bug?
>>> > >>>
>>> > >>>
>>> > >>> Thank you
>>> > >>>
>>> > >>> --
>>> > >>> Regards,
>>> > >>>
>>> > >>> Gabriel Sobrinho
>>> > >>> E-mail: [email protected]
>>> > >>> Phone: +55 31 8775 8378
>>> > >>>
>>> > >>> Don't print this e-mail. The nature is thankful and your money
>>> also.
>>> > >>
>>> > >> --
>>> > >> Regards,
>>> > >>
>>> > >> Gabriel Sobrinho
>>> > >> E-mail: [email protected]
>>> > >> Phone: +55 31 8775 8378
>>> > >>
>>> > >> Don't print this e-mail. The nature is thankful and your money also.
>>> > >
>>> > > --
>>> > > Regards,
>>> > >
>>> > > Gabriel Sobrinho
>>> > > E-mail: [email protected]
>>> > > Phone: +55 31 8775 8378
>>> > >
>>> > > Don't print this e-mail. The nature is thankful and your money also.
>>>
>>> --
>>> Sergio Cambra .:: entreCables S.L. ::.
>>> Mariana Pineda 23, 50.018 Zaragoza
>>> T) 902 021 404 F) 976 52 98 07 E) [email protected]
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Regards,
>>
>> Gabriel Sobrinho
>> E-mail: [email protected]
>> Phone: +55 31 8775 8378
>>
>> Don't print this e-mail. The nature is thankful and your money also.
>>
>>
>>
>
> >
>


-- 
Regards,

Gabriel Sobrinho
E-mail: [email protected]
Phone: +55 31 8775 8378

Don't print this e-mail. The nature is thankful and your money also.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to