I have a controller FormsController and a Active Model ApplicationForm. I have made this model by including include ActiveModel::Validations
, include ActiveModel::Conversion
, extend ActiveModel::Naming
. When I'm using @form=ApplicationForm
I'm getting NameError uninitialized constant FormsController::ApplicationForm
. How do I resolve this issue, I just want to use this Model as class which can provide object to hold form values temporarily for further processing.
Asked
Active
Viewed 58 times
0

dushyantashu
- 523
- 3
- 9
- 16
1 Answers
0
Here is how to use it from a directory. Assuming it is in a directory app/forms and you have done correctly added the forms to the autoload paths for rails.
@form = ::Forms::ApplicationForm.new(your_params)
Your module will have to be named like this
module Forms
class ApplicationForm
#your form code
end
end

Austio
- 5,939
- 20
- 34
-
Thanks! But if I keep my model file in some other directory, how do I use it? – dushyantashu Jul 19 '15 at 15:49
-
you will have to change a couple things. I'll update answer to get you what you need. – Austio Jul 19 '15 at 18:16