activeform-rails
activeform-rails copied to clipboard
Apologies for ruby/rails newbie question - I get errors regarding UnpersistentModel
Hello,
Sorry for the newbie issue, but I have problems validating an object I create using activeform-rails.
I created a new class, and included ActiveForm::Form and ActiveForm::ValidateUniqueness. When I attempt to validate a valid object (valid?), it works fine. When I attempt to validate an invalid object, I get "NameError: uninitialized constant ActiveForm::Form::ClassMethods::UnpersistentModel".
If I put in my class "include ActiveForm::UnpersistentModel" I get "NameError: uninitialized constant ActiveForm::UnpersistentModel".
If I put in my .rb file (or on my irb console) the actual code from the unpersistent_model.rb file, everything works fine.
I am sure I am doing something simple incorrectly, perhaps mixing ActiveForm::UnpersistentModel into my class incorrectly.
Your help appreciated.
Hello,
Can you try ActiveForm::Form::UnpersistendModel
? It should work.
Unfortunately that did not work either, though it resulted in a different error.
Here's the code I am using in irb:
require 'rails' require 'active_record' require 'activeform-rails'
class Query include ActiveForm::Form include ActiveForm::ValidateUniqueness include ActiveForm::Form::UnpersistentModel end
This results in:
TypeError: wrong argument type Class (expected Module)
from (irb):7:in include' from (irb):7:in
class:Query'
from (irb):4
from /Users/acaeti/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `
Yes, UnpersistentModel
is a class. You must to do something like this :
require 'rails'
require 'active_record'
require 'activeform-rails'
class Query < ActiveForm::Form::UnpersistentModel
include ActiveForm::Form
include ActiveForm::ValidateUniqueness
end
Yesterday, I found this project. I think I will stop my project because the Rails one do the same thing and is maintened by the Rails team.