Closed GoogleCodeExporter closed 9 years ago
In ContactsController, define joins_for_collection if you want to add a join (as
joins option of AR::find), or add your association to active_scaffold_joins if
you
want to add an include
Original comment by sergio.c...@gmail.com
on 15 Dec 2009 at 2:20
Also, you can change config.list.sorting in a before_filter to order only by
full_name when is nested.
Original comment by sergio.c...@gmail.com
on 15 Dec 2009 at 2:23
Hi Sergio,
Sorry to be so helpless.
Would you mind providing some code examples for both proposed solutions?
Thank you!
Original comment by netv...@gmail.com
on 15 Dec 2009 at 10:01
For the before_filter solution, I have created a filter like this:
private
def adjust_sorting
if params.has_key?(:nested)
active_scaffold_config.list.sorting = [{ :full_name => :asc }]
else
active_scaffold_config.list.sorting = [{:company => :asc}, { :full_name => :asc }]
end
end
This works. However I'm wondering if there is better solution? I noticed that
has_key? method is deprecated in the latest Rails as per this:
http://apidock.com/rails/Rack/Utils/HeaderHash/has_key%3F
Original comment by netv...@gmail.com
on 15 Dec 2009 at 10:25
I'm not sure params is a HeaderHash, anyway you can try with params[:nested]
too.
Original comment by sergio.c...@gmail.com
on 16 Dec 2009 at 8:49
Hmmm... you're correct params is actually a HashWithIndifferentAccess...
Which inherits Hash's methods including has_key?.
But somewhere along the lines as I was testing ways to fix this issue, I got a
deprecation notice about has_key?, after a bit of googling I got to that link.
In any case I have it solved with the before_filter as above.
However, I'm interested in the joins_for_collection way of solving this.
Would you care to post a wee bit more code. I'm coming up short with google for
actual examples that would be relevant.
Thank you in advance!
Original comment by netv...@gmail.com
on 16 Dec 2009 at 9:22
Original issue reported on code.google.com by
netv...@gmail.com
on 15 Dec 2009 at 1:51