Define parameters in controller

Posted about 5 years ago by Bennett Allen
Posted about 5 years ago by Bennett Allen

In my view form I want some fields to automatically populate when the user creates a new form instead of the user having the options of inputting. For instance when the user creates form version #2 I want some data from form version #1 to populate automatically. I'm thinking I need to do this in the invoice controller in the "def new" method?

0
Posted about 5 years ago by Alex Yang

Precisely. You'll need to define what your form object is going to be. Typically, it'll be a blank object, something like '@object = Object.new'. In this case, you'll want it to instead have the attributes of the previous object from version #1. I'm not sure, but you might be able to do something like this '@object = Object.last.dup'.

0