JannaB wrote ...
>
> belongs_to :associate
>
> thus I have a column in my activities table called associate_id.
>
> In my ActivitiesController, I specify:
>
> config.columns[:associate].form_ui = :select
>
> And in my Associate model, I have:
>
> def to_s
> p = lastname.to_s+", "+firstname.to_s+ " "+middlename.to_s
> p.to_s.strip
> end
>
> All is well, and in the dowpdown select for the associate_id my
> Activity form, I see a list of nicely formatted names in ascending
> alphabetical order based on last name.
>
> However, there is also a helper method in my application controller
> as:
>
> helper_method :current_associate
>
> so that I may access the current_associate (the Associate object of
> the person logged in) from all other controllers.
>
> I would LIKE, only when I do a CREATE on an activity, to have the
> dropdown select box I described in my Activity form, for the
> associate_id, to default to current_associate, i.e. default to the
> Associate who is logged in and creating the Activity.
>
> How can I do this? I've looked through the docs but dont see anything?
> Is there a function for column that is new for doing this? How would
> you do this? Thanks, Janna B.
Define #do_new in your ActivitiesController and set the associate on
the newly created record. Something like
def do_new
super
@record.associate_id = current_associate.id
end
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---