hzamani / active_record-acts_as

Simulate multi-table inheritance for activerecord models
MIT License
252 stars 86 forks source link

Object does not keeps the attributes submited #74

Open wbotelhos opened 8 years ago

wbotelhos commented 8 years ago

When I submit:

post :create, exam: { name: 'name', description: nil }

And validation fails because description is mandatory:

if @exam.save
else
  render :new
end

The @exam object does not keeps the submited value.

<%= f.text_field :name %> # nil

I need to manually set the acting_as data:

@exam.attributes = create_params

Even the errors:

@exam.acting_as.errors.each do |key, value|
  @exam.errors.add key, value
end

Uses delegate on model does not works for the attributes and I do not found a way to delegate the errors.

I missing something here or it is the normal behavior?

Thanks e congrats for the great gem. (:

manuelmeurer commented 7 years ago

Hi @wbotelhos, could you write a test or a sample app that recreates this problem? It's hard to follow without seeing your custom models and controllers.