I have i question about automatic form generation when using rich many-
to-many joins in Hobo.

Firstly, i have 2 models:

class Associate
  fields do
    name  :string
    email :string
    timestamps
  end
  has_many :portfolio_associates, :dependent => :destroy
  has_many :portfolios, :through => :portfolio_associates

class Portfolio < ActiveRecord::Base
  fields do
    name        :string
    description :text
    started_at  :date
    ended_at    :date
    timestamps
  end
  has_many :portfolio_associates, :dependent => :destroy
  has_many :associates, :through => :portfolio_associates

And a binding model:

class PortfolioAssociate < ActiveRecord::Base
  fields do
    role enum_string(:student, :supervisor, :external_contact)
    timestamps
  end
  belongs_to :associate
  belongs_to :portfolio

When i create i new portfolio, i would like to be able to associate
associates to the portfolio, and give these associates different
roles. I kind of works, but not 100% percent. Here are the glitches:

- When i make the :associates accessible to the portfolio, i can
create a new portfolio without problem, and add and delete all
associated associates without any problem, BUT i cannot set the role
of the portfolio association.
- When i make the :portfolio_associates accessible to the portfolio, i
can set the role, but i HAVE to assign at least one association for
the portfolio entry to be saved correctly, otherwise the one
portfolio_association in the create form doe's not have a associate
selected, and that breaks the join.

Ny question is how can i secure that i can both create a portfolio
WITHOUT any association AND make is possible to assign roles to the
associations?

--

You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en.


Reply via email to