Difference between Using Postgres instead of working directly with database


(SMHassanAlavi) #1

This is my plugin.

because I don’t know how to add with postgres, I have added them directly. so should I change the sequence if I want to work exavtly like discourse? instead of using postgres?
If I add increment directly to user_custom_fields_id_seq, Will my problem be solved?

NOTE:I found a function that is add_to_serializer.
Can anyone help me using this function.


(Simon Cossar) #2

The RailsGuides have a lot of good information. This might be useful: Active Record Query Interface — Ruby on Rails Guides


(SMHassanAlavi) #3

The probelm is How discourse save data into user_custom_fields. I have searched a lot in discourse repository but I don’f find the model.


(David Taylor) #4

This thread has some examples:


(SMHassanAlavi) #5

My problem is not creating user_custom_fields. I have created them. but now the problem is adding info to them for each user.
until now I used:

INSERT INTO user_custom_fields (id, user_id, name, value, created_at, updated_at) VALUES (#{last_id}, #{user_id}, 'user_field_5', '#{userexpertis}', '#{formatted_time}', '#{formatted_time}')

but doing this won’t increase the sequence.