Thanks Sergio.
Thinking though..
I have some through associations going on in several of my models though
that I'd like to only select from the through association that is set up.
eg:
class Workflow < ActiveRecord::Base
belongs_to :ud
has_one :organization, through: :udt
has_many :active_memberships, through: :organization
belongs_to :workflow_owner # I need select user_id from
:active_memberships
end
Is there a slick way to accomplish this I can create a select with just the
user_id in membership? Do I need to override the column to do this? I'd
like to do this is in a number of areas with other things as well like:
has_many :workflow_manager_groups, ->{ where performance_type: 'manager'},
as: :groupable, class_name: 'GroupPerformer'
has_many :workflow_performer_groups, ->{ where performance_type:
'performer'},
as: :groupable, class_name: 'GroupPerformer'
has_one :project, through: :udt
has_many :groups, through: :project
has_many :users, through: :groups
where this is selecting through :groups
I guess it would be ok to do something like (pseudo code)
config.columns[:workflow_owner].form_ui = :select
config.columns[:workflow_owner].options = users.pluck(:user_id, :username)
Not sure that is even possible that would need to be a proc or something.
I checked out the association_klass_scoped or
options_for_association_conditions
but I am trying my best to stay away from hardcoding anything..but if
necessary I will!
Thanks in advance Sergio.
On Wed, Feb 3, 2016 at 4:30 AM, Sergio Cambra <[email protected]>
wrote:
> You need to use association_klass_scoped or
> options_for_association_conditions
> in the helper to restrict which options are included in select.
>
>
> https://github.com/activescaffold/active_scaffold/wiki/Custom-Association-Options
>
> El martes, 2 de febrero de 2016 5:44:45 (CET) loveand light escribió:
> > I have simple update to an associations called 'conditions' that
> contains
> > 2 select fields that need to be updated after the user selects which
> 'udt'
> > needed
> >
> > In the controller I put:
> >
> > config.columns[:udt].update_columns = :conditions # enables the
> > "magic"
> > config.columns[:udt].send_form_on_update_column = true
> >
> >
> > this looks to do the right thing... but now I need to set the
> corresponding
> > association array into the current record object. Instead of the entire
> > project, I want to display ONLY the ones that are in this assoc which I
> can
> > get from the 'record' object passed into the
> >
> > class AdvancedSearch < ActiveRecord::Base
> > has_many :conditions, class_name: 'AdvancedSearchCondition'
> > belongs_to :udt # udt to search
> > end
> >
> > protected
> > def after_render_field(record, column)
> > if column.name == :udt
> > record.udt.udt_fields'
> > end
> > end
> >
> >
> > This is an advanced search object so I just want to select the fields
> that
> > are in the associaiton: 'udt'...
> >
> > => #<AdvancedSearch:0x007fdeab199970
> > id: nil,
> > project_id: 1,
> > name: nil,
> > description: nil,
> > user_id: nil,
> > udt_id: 3,
> > created_at: nil,
> > updated_at: nil>
> >
> > so 'record.udt.udt_fields' gets the the fields I need but now I need to
> > update the select to show only these fields.
> >
> > This seems pretty trial but I am have a time trying to get to work..
> >
> > Does anyone have any knowledge as to how to do something like this?
> >
> > Thanks!
>
>
>
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.