How to get id values after saving an ActiveRecord model in rails
For people who looking for on create in model, below is the way:
class User < ActiveRecord::Base
...
after_create :do_something
def self.do_something
user_id = id #this will have last created id
# use this according to your needs
end
...
end
Just call user.id
after you've saved.