Sunday, April 3, 2011

Making forms in Rails

So far I've built a simple form for a user using the form_for method to wrap around my user model.

But if I'm going to create a form now which doesn't doesn't map directly to any particular model, should I still be using form_for?

From stackoverflow
  • You probably just want form_tag.

  • There are a few plugins which allow you to create an active record like model without having to have a database behind it. I would point you to a plugin that gives you this functionality, but I'm not sure which ones are still compatible with Rails 2.x.

    If you were to go this route you could create a view mode, use form_for as you would normally and get all the validation stuff thrown in.

    I've used this to great effect for things like login forms and the like.

0 comments:

Post a Comment