I have a simple user table and i would like to add a new field to my user table that says permalink. This permalink would be updated with the following code for all the users
name.downcase.gsub(/[^0-9a-z]+/, ' ').strip.gsub(' ', '-'). I want to create a migration file that updates all the users permalink fields with the code above so that old users would have their permalink set and i would use an after_create method for new users.
I have a simple user table and i would like to add a new
Share
I think you could try something like this:
This actually uses the
before_createcallback, which would address the deriving of thepermalinkfield for new users. I think this is what you actually need.And in your migration file …
.. which would take care of any existing
Users that do not have this field set just yet.