Hi,

if you do not want to set that value in general but only for that
specific controller you may override do_new

def do_new
  super
  @record.xyz = default_value
  @record
end

if you want to only set the default value if you are nested you can
also check if you are currently nested, please take a look into
nested.rb to see the corresponding methods.

--
Volker

Swartz schrieb:
> You can define initialize method in the Financing model something
> along the lines
>
> # lets set the default params for a new awardation
>   def initialize(params = {})
>     params[:start_of_period] ||=
> Financing.find.previous.end_of_period
>     super(params)
>   end
>
> It basically pre-initializes a record with some values.
> Hope it makes sense.
>
>
> On Jun 23, 3:11 am, Andrey Voronkov <[email protected]> wrote:
> > I have such models:
> >
> > FinancingPeriod
> >   belongs_to :event
> >   has_many :financings
> >   # it has date column in it's table
> > end
> >
> > Financing
> >   belongs_to :financing_period
> > end
> >
> > So when I create a new financing in nested frame (from the period) I want to
> > intial values in fields were from first(last) financing record from previous
> > by date period.
> > Has anybody any ideas how to do that?

-- 
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