0

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.

dushyantashu
  • 523
  • 3
  • 9
  • 16

1 Answers1

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