#447 ✓resolved
Adam Hoscilo

Validation problems with has_many :accessible => true

Reported by Adam Hoscilo | June 19th, 2009 @ 10:50 AM | in Hobo 1.0 - Final

Description (on hobo 0.8.7):

Category:
  has_many :things, :dependent => :destroy, :accessible => true

Thing:
  fields do
    price :decimal, :precision => 6, :scale => 2
    is_active :boolean, :default => true
    timestamps
  end
  belongs_to :category
  belongs_to :thing_pattern
  has_many :somethings
  validates_presence_of :price, :category, :thing_pattern 

  <def tag="form" for="Category">
  ...
    <hr/>
    <div param="things-forms">
      <p><b>Things:</b></p>
      <input-many:things>
        <div param="card">
          <field-list fields="price, thing_pattern"/>
          <check-many:somethings/>
        </div>
      </input-many>
    </div>

Problem:
After saving this form things are created first, what leads to validation error on category. Partial solution is to make validation :on => :update but that can make the data inconsistent

Solution:

Maybe first create main model, then all associations?

Comments and changes to this ticket

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

Referenced by

Pages