Using AS 1.2 and Rails 2.3.14
I want to use the results of an instance method on the model (setup as a
virtual column in AS) to sort. The instance method filters a collection of
child objects based on parameters passed by the parent. Not sure if a proc
would work here, and what the syntax would look like if it would. This
controller code does not cause errors, but it also does not sort properly.
class Challenge < ActiveRecord::Base
...
has_and_belongs_to_many :users
...
end
class user < ActiveRecord::Base
has_and_belongs_to_many :challenges
...
def training_sessions_by_challenge(challenge)
#returns filtered collection of sessions that meet the criteria of the
supplied challenge instance
end
end
class UsersController < ApplicationController
before_filter :customize_config
active_scaffold do |config|
...
end
protected
def customize_config
if active_scaffold_constraints[:challenges]
@challenge =
Challenge.find(active_scaffold_constraints[:challenges].to_i
active_scaffold_config.columns[:training_sessions_count].sort_by
:method => "training_sessions_by_challenge(@challenge).count"
end
end
Thanks in advance for any help,
Matt
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/activescaffold/-/JrAZ8m8CafkJ.
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.