I have created a sequence in a migration that I want to be used in both creates and updates. I’m thinking that I can create a before save filter that will setup the sequence, but I’m not sure how to ‘inject’ the SQL required (in this case nextval('sequence')). My query will need to look something like this:
UPDATE users
SET
sequence=nextval('users_sequence'),
name='Kevin',
...
WHERE id=...
Note that I unfortunately cannot create a trigger to do this as I am deploying on Heroku’s shared database and don’t have access to PLPGSQL.
In your
before_filterwrite something like:Hope this helps.