dynamic_form icon indicating copy to clipboard operation
dynamic_form copied to clipboard

POROs and `@#<PORO>' is not allowed as an instance variable name

Open openfirmware opened this issue 10 years ago • 0 comments

Not really an issue as I solved it, but something to note for other users of dynamic_form.

I was implementing dynamic_form with a Plain Old Ruby Object that includes ActiveModel::Validations, and was getting the error in the subject line when trying to use <%= f.error_messages %>.

I didn't find any other instances of this issue, but it can be solved by defining to_model in the PORO:

class Download
  include ActiveModel::Validations
  attr_accessor :name
  validates_presence_of :name

  def to_model
    self
  end
end

Thanks for the gem, works great.

openfirmware avatar Apr 11 '14 18:04 openfirmware