Thanks for reply,

1)Yes ive used helpers to override columns but cant seem to get the
multi-check-box to work.  Is there any examples kicking
about?

2) What i mean by extra sql keys is there any way i can add custom
joins or an order_by clause for example in the
options_for_association_conditions.

So something like my example below:
if association.name == :surveys
  company_id = @record.primary_survey.user.company_id
   :joins => 'blah...............,
   :conditions => ["users.company_id = ?",company_id],
   :order_by => ["users.name ASC]
  else
   super
end

I know i could set the default order on the model but say i wanted a
custom order by and include another join.

At the moment it looks like we can just add conditions in
options_for_association_conditions as per below

def options_for_association_conditions(association)
 if association.name == :surveys
 client_id = @record.primary_survey.user_id
["surveys.user_id = ?",client_id]
 else
 super
end

JB


On Jan 7, 3:08 pm, "mr.gaffo" <[email protected]> wrote:
> 1) Use a helper column override.
> 2) what do you mean by extra "sql keys"? Tables? Params mapping to ? ?
>
> On Jan 6, 7:32 am, johnnybutler7 <[email protected]> wrote:
>
> > Hi,
>
> > A few questions on this that im stuck on, hopefully someone can help
> > me out.
>
> > 1)I have the following code below which gives a multiple checkboxes
> > which is what i want,
>
> > config.columns[:surveys].ui_type = :select
>
> > I have a column called name on the surveys model which it defaults to
> > but i want to change this to
> > #{surveys.name} #{surveys.score} but i dont want to overide the
> > to_label method as this model is used in other active scaffolds where
> > i want just the name displayed and not the score.  Whats the easiest
> > way to this?
>
> > 2) For the same column i want to filter what surveys are diaplyed
> > depending on what the company of the user is.
> > So i have :
>
> > def options_for_association_conditions(association)
> >   if association.name == :surveys
> >    client_id = @record.primary_survey.user_id
> >        ["surveys.user_id = ?",client_id]
> >     else
> >       super
> >    end
>
> > This works fine however i really want it so it displays all surveys
> > that belong to a users company so something like:
>
> > def options_for_association_conditions(association)
> >   if association.name == :surveys
> >    company_id = @record.primary_survey.user.company_id
> >        :joins => 'blah...............,
> >       :conditions => ["users.company_id = ?",company_id],
> >     else
> >       super
> >    end
>
> > Is there any way to add extra sql keys aswell as the conditions?
>
> > thanks
>
> > JB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to