James Osborn
James Osborn

Reputation: 187

Rails 3: Auto-populating a table upon new user creation with Devise

I'm using devise to handle my users and as part of my application each user has their own 'todo' list. I'm trying to create 5 items in a new list every time a new user is created (so they have some sample data).

What is the best way to do this? I've looked at migrations and seed.rb but these don't seem to meet my needs.

Any help would be really appreciated!

Cheers!

Upvotes: 2

Views: 165

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230396

use :after_create hook.

class User < ActiveRecord::Base

  after_create :populate_todo

  private
  def populate_todo
    # do your stuff here
  end
end

Upvotes: 1

Related Questions