PiRSquared17 / activescaffold

Automatically exported from code.google.com/p/activescaffold
MIT License
0 stars 0 forks source link

When using nested scaffold action, sorting on the nested scaffold breaks when using sort_by... #774

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create scaffold hosts [id,hostname]
2. Create scaffold hosts_boards [host_id,boardmodel_id,boardver_id]
3. Create scaffold boardmodels [id,board_model]
4. Create scaffold boardvers [id,board_ver]
5. Add sorting on hosts_boards

config.columns[:boardmodel].sort_by :sql => "boardmodels.board_model" 
config.columns[:boardvers].sort_by :sql => "boardvers.board_ver" 
config.list.sorting = { :boardmodel => :asc }

6. Add nested link on boardmodels 

[config.nested.add_link(:host_boards, :label => "Host Boards")]

7. Add nested link on boardvers 

[config.nested.add_link(:host_boards, :label => "Host Boards")]

What is the expected output? What do you see instead?

When selecting the nested action link on the boardmodels and boardsvers I would 
expect the nested scaffold to appear and sorted by boardmodel sort_by method 
(ie 'board_models.boardmodel).

This will only work on the controller if the field being sorted by is not the 
controller you are showing the nested scaffold from ie:

Sorted by boardmodel will work on boardvers controller,
Sorted by boardver will work on boardmodels controller,
Sorted by boardmodel will NOT work on boardmodels controller,
Sorted by boardver will NOT work on boardvers controller,

If the sort_by method is NOT defined for either fields then either case will 
work. This is not really ideal as I dont want to sort by id and would like to 
use the field in the sort_by definition.

If the sorting is on the model you are using the sort_by method to show nested 
then mysql will error with:

ActiveRecord::StatementInvalid (Mysql2::Error: Unknown column 
'board_models.boardmodel' in 'order clause'...

This used to work in rails below version 3.0.

What version (or revision) of the product are you using?

Active Scaffold 3.0.25

Regards
James

Original issue reported on code.google.com by james.co...@gmail.com on 19 Dec 2011 at 2:41

GoogleCodeExporter commented 9 years ago
Report bugs in github, as you can see there is no link to issues in google code 
because we are using now github

Original comment by sergio.c...@gmail.com on 19 Dec 2011 at 8:35