Re: Another session question

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Another session question

Tom Davies-3
Hi Scott,

Perhaps you can just store the individual params in the session such as:

And then when all of your information is collected, you could have
your project model be responsible for creating its dependencies, such

  Project.create(session[:new_contractor], session[:new_billing],

The Project model would then create each of the individual
dependencies.  You could then wrap them all in a transaction so that
if one fails, they all will.  You could also perform any business
logic related to storing these objects withing that method.


On 12/15/05, Scott Phelps <[hidden email]> wrote:

> On Dec 15, 2005, at 4:41 PM, Tom Davies wrote:
> >
> > However, another option may be to store this logic in your product
> > model, so that no matter where you store your products from, you could
> > assign the category within the model.
> That sounds more ideal.  Let me be more specific....
> Note I am switching from Product to Project now
> I have a models set up like this:
> ---------------------------------
> class Project < ActiveRecord::Base
>    has_one :contractor_item, :dependent => true
>    has_one :billing_item, :dependent => true
>    has_one :engineer_item, :dependent => true
> end
> class ContractorItem < ActiveRecord::Base
>    belongs_to :project
> end
> class BillingItem < ActiveRecord::Base
>    belongs_to :project
> end
> class EngineerItem < ActiveRecord::Base
>    belongs_to :project
> end
> Now, to create a new Project I have these views:
> ------------------------------------------------
> new_contractor_item
> new_billing_item
> new_engineer_item
>  >>> These views are set up as CSS tabs that the user can click
> between and modify before clicking a "Create Project" link.
> The goal is to collect all of the form data in a session and have
> that form data repopulated during the Project creation until the user
> clicks "Create Project" upon which the session will be reset and the
> Objects will get saved to the database (after validation - of course)
> I would love to do this all in the Project model, but I could not
> find how to add these multiple objects to the same session within one
> Project Model.
> TIA!
> _______________________________________________
> Rails mailing list
> [hidden email]
Rails mailing list
[hidden email]