Forum: Ruby on Rails Pre Custom Objects and Stuff - Easy Answer im sure

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
428f1d76da99d9602d57b046841df29a?d=identicon&s=25 Dave Smith (railsnoob)
on 2009-01-12 15:31
Hi Guys,

When I create a project I would like to be able to create a default set
of tasks for that project.

One could have a line for each task to manually add each project_task in
the projects controller when creating the project but that would be poor
programming im sure.!

Is there a way of achieving this, perhaps making pre-customised objects
in a config file or something?

Cheers Folks,

Dave
428f1d76da99d9602d57b046841df29a?d=identicon&s=25 Dave Smith (railsnoob)
on 2009-01-13 12:10
Dave Smith wrote:
> Hi Guys,
>
> When I create a project I would like to be able to create a default set
> of tasks for that project.
>
> One could have a line for each task to manually add each project_task in
> the projects controller when creating the project but that would be poor
> programming im sure.!
>
> Is there a way of achieving this, perhaps making pre-customised objects
> in a config file or something?
>
> Cheers Folks,
>
> Dave

Any ideas guys?
D188e591eac11021329b8821a5f954c7?d=identicon&s=25 Ar Chron (railsdog)
on 2009-01-13 18:06
http://api.rubyonrails.org/

Module
ActiveRecord::Callbacks

Callbacks are hooks into the lifecycle of an Active Record object that
allow you to trigger logic before or after an alteration of the object
state. This can be used to make sure that associated and dependent
objects are deleted when destroy is called (by overwriting
before_destroy) or to massage attributes before they‘re validated (by
overwriting before_validation). As an example of the callbacks
initiated, consider the Base#save call for a new record:

Perhaps an after_save method for your Project class could create a
default set of Tasks...
This topic is locked and can not be replied to.