Matt, et. al.,
Relevant code for the simplest case (agent, sort by state_prov):
agent.rb
<snip>
name :string, :name=>true, :index=>true, :primary_content=>true
timestamps
end
belongs_to :state_prov
</snip>
state_prov.rb
<snip>
name :string, :name => true
abbreviation :string
timestamps
end
has_many :agents
</snip>
agents_controller.rb
<snip>
hobo_index Agent.apply_scopes(:search => [params[:search],:name],
:order_by =>
parse_sort_param(:name, :address1, :city, :postal_code, :state_prov))
</snip>
agents/index.dryml
<snip>
<page-nav param="top-page-nav"/>
<table-plus fields="this, address1, city, state_prov, postal_code" param/>
<page-nav param="bottom-page-nav"/>
</snip>
I changed the agents_controller.rb file to read:
hobo_index Agent.apply_scopes(:search => [params[:search],:name],
:order_by => ["state_prov","asc"]
which simulates the output of parse_sort_param when State Prov is
selected and I get the totally blank rendering,
Looking inside the apply_scopes code, it appears that apply scopes is
working correctly. The result of apply_scopes when the order_by is
["state_prov", "asc"] is, in fact, ordered by state_prov. (At the
beginning of apply_scopes, the order is by name which is the default.
Don Z.
On 4/26/2011 12:42 PM, Matt Jones wrote:
On Apr 26, 2011, at 11:46 AM, Donald R. Ziesig wrote:
Hi All, Its me again!
Sometimes beta testers can be a pain in the *, but they often find the most
amazing problems.
I have numerous situations where I want to be able to sort a table-plus based
on the value of a belongs_to field as in:
belongs_to :state_prov
belongs_to :agent
in a simple table-plus header:
Name Address City State/Prov PostalCode Agent
The correct values appear when the table is displayed, but when the beta-tester
clicks on the header for either of these fields (for example, they want to sort
clients by their state/province or properties by their listing agent), they get
a totally blank rendering.
There is nothing there. No menu, no header stuff, its totally blank!
Very strange - can you post the DRYML for the table-plus? The automatic order_by
scope is supposed to handle sorting by 'some_belongs_to_association' as long as
the model involved has a field declared with :name => true.
P.S. These fields appear as links in the table. In some cases the link is
rather trivial (e.g. the state/province displays the name and abbreviation of
the state or province). I would like to tell table-plus to just display these
without creating a link.
If you've got a bunch of these, you'll probably want to declare a<view> tag
for the appropriate class; in a singular instance, you can swap out what table-plus
shows for a cell with:
<table-plus ...>
<agent-view:>
...do something useful here - 'this' is the Agent object here
</agent-view:>
</table-plus>
--Matt Jones
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en.