Blog

Custom field example for Ruby on Rails with Activerecord & PostgreSQL & Metaprogramming

Hi,

Sometimes instead of specific db fields, you want to store custom field on database that is changing according to user needs in same app.

I coded following method to store this type of dynamic data. As you see in codes, it uses metaprogramming methods.

Also, there is simple validation to custom field that is number.

There is simple rails app that is using this type of custom field method. You can access source code below link:

https://github.com/lab2023/postgresql_jsonb_ransack_rails_5

If you want to demo, there you go: https://rails-custom-field-ransack.herokuapp.com

Happy coding..


Posted

in

, ,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *