What’s the Rails way?

Right, I finally figured out the way to get tabular data sorted on the index page by way of a non-numeric associated table B, by way of a class method and scope (to limit the selection to the first letter of the name in table A) but it means that my controller needs to check the value the column selection param and run a different query when sorting by that column.

I could add a custom route to the controller and just render the index page. But that will probably mean splitting my session variable processing across different actions.

I guess what I really should do is put all the session processing in the before_action setup method and keep the index and custom actions neat and tidy.

And then there’s the question of the matter of the simple select form to display only items in table A that have a reference to table B as pointed to by the select.

Or perhaps I consider all this as basic search functionality and incorporate into the search actions that I will need to do anyway.

One step at at a time: tidy up the session handling.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s