#910 ✓invalid
Don Ziesig

Sti object as child of normal object has mutually exclusive issue.

Reported by Don Ziesig | January 28th, 2011 @ 03:27 PM | in Hobo 1.3 (Rails 3)

I have a normal object - property - with a child - transaction - that uses sti to specialize the different types of transactions allowed on a property (e.g. seller_transaction, buyer_transaction).

In the property.rb file, I have:

has_many :transactions ### Problem line

has_many :buyer_transactions
has_many :seller_transactions

children :seller_transactions
children :buyer_transactions

If the problem line above is present, I can not create seller_transactions or buyer_transactions. The Add boxes are visible on the property page(after a little editing of the dryml), but the contents are absent and there is no Add button. If I enter the transactions directly in the database, I can view the list of all transactions associated with a property (again with a little editing of the dryml) using the line:

<collection:transactions param/>

On the other hand, if the problem line is absent, I can create both seller_transactions and buyer_transactions (after a little editing of the dryml), but I can not (crash) view a list of transactions associated with the property. It does NOT like the line

<collection:transactions param/>

As a work around, I essentially have to separate the two (in the real app many more) lines:

<collection:buyer_transactions param/>
<collection:seller_transactions param/>

which is a real PITA (and will cause the users grief because they will want to sort the transactions as a group, not separately).

Comments and changes to this ticket

  • Domizio Demichelis

    Domizio Demichelis March 21st, 2011 @ 05:41 PM

    • State changed from “new” to “invalid”
    • Milestone set to Hobo 1.3 (Rails 3)
    • Assigned user set to “Domizio Demichelis”
    • Milestone order changed from “197945” to “0”

    I tried your app, and what you are trying to do seems a customization on the show page.

    The canonical way to add children to a parent record is just add :accessible => true to the Property model for the transaction type that you want to be able to add (incuded the general transaction) and edit it in the property EDIT/NEW page.

    That is working in your attached app, so there is no bugs here.

    I suggest you to post in the hobousers group, so somebody will help you to customize what you need.

  • Domizio Demichelis

    Domizio Demichelis March 21st, 2011 @ 06:52 PM

    • State changed from “invalid” to “open”

    ops... sorry, I didn't get it the first time :-)

  • Domizio Demichelis

    Domizio Demichelis March 21st, 2011 @ 07:41 PM

    • State changed from “open” to “invalid”

    well, if you add:

    auto_actions_for :property, [:create]

    to the TransactionController your app will get the route that the form needs in order to be posted somewhere, and it will work with the transactions children out of the box. If you want to use the STI base class instead the sti classes, you have also to customize the transactions form so you can choose which kind of transaction will be created.

    So no bugs again :-@

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Attachments

Pages