How do you get the id of a rails model before it is saved?
For example, if I create a new model instance, how can I get its ID before it is saved?
I know t
I was looking for this too, and I found an answer:
Let's suppose model name is "Model" and table name is "models"
model.rb
before_save { next_id=Model.connection.select_value("Select nextval('models_id_seq')") }
This will output the value your record will take for id IF it gets saved