ryanburnette / rcms

My learning rails project and long term Rails CMS. Not ready for primetime.
0 stars 0 forks source link

Key/value pair meta #12

Closed ryanburnette closed 10 years ago

ryanburnette commented 10 years ago

There may be cases where I have a special template for a post or page view that gets used maybe only once or twice. I might need to store some information from the CMS for displaying that unique post. In WordPress I'm used to using key/value pair meta which is associated with the post object for this type of storage. For fields that will be used repeatedly I plan to define fields in my models, but for lightly used situations is this still a viable approach in Rails?

paulelliott commented 10 years ago

I'm not sure I quite understand your question. Can you give me a concrete example?

ryanburnette commented 10 years ago

Say I have a page that has several areas where the user can enter text and that text is displayed. It's a unique template just for that one page. Rather than adjusting my model for page I might store those values as key/value meta. So there would be a model for post_meta with two fields, key and value. Each post_meta object would belong to a post, page, or any other inherited type.

This way when I had special cms use cases I wouldn't need to adjust my post model. In cases where the same data pattern would be used repeatedly I wouldn't use this method.

Or perhaps I should take some other approach like serializing the data and storing it in a single field that all posts have.

On Thu, Feb 6, 2014 at 9:23 AM, Paul Elliott notifications@github.comwrote:

I'm not sure I quite understand your question. Can you give me a concrete example?

— Reply to this email directly or view it on GitHubhttps://github.com/ryanburnette/rcms/issues/12#issuecomment-34326887 .

paulelliott commented 10 years ago

This sounds like it might be a good candidate for an hstore in postgres.

ryanburnette commented 10 years ago

I've just been using MySQL up to this point because I'm familiar with it. Most of the training courses I've used so far have used MySQL as well.

On Thu, Feb 6, 2014 at 9:34 AM, Paul Elliott notifications@github.comwrote:

This sounds like it might be a good candidate for an hstore in postgres.

— Reply to this email directly or view it on GitHubhttps://github.com/ryanburnette/rcms/issues/12#issuecomment-34327922 .

paulelliott commented 10 years ago

It really wouldn't be much different with rails except that you can do a lot of advanced stuff like hstore, array fields, and json fields. Most rails shops use postgres, so you should definitely check it out.

ryanburnette commented 10 years ago

After thinking about this for a bit it just makes sense to serialize data into a meta field if I want to do this. And it sounds like Postgres lends itself to this sort of storage.

For now I'm learning a lot so I'll stick with MySQL, but I'll keep learning Postgres in the front of the back burner queue.