Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apologies for ruby/rails newbie question - I get errors regarding UnpersistentModel #5

Open
acaeti opened this issue Nov 3, 2014 · 3 comments

Comments

@acaeti
Copy link

acaeti commented Nov 3, 2014

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.

@GCorbel
Copy link
Owner

GCorbel commented Nov 3, 2014

Hello,

Can you try ActiveForm::Form::UnpersistendModel? It should work.

@acaeti
Copy link
Author

acaeti commented Nov 4, 2014

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:inclass:Query'
from (irb):4
from /Users/acaeti/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `

'

@GCorbel
Copy link
Owner

GCorbel commented Nov 4, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants