开发者

User preferences in Rails with Admin edit and i18n support

开发者 https://www.devze.com 2023-03-28 14:48 出处:网络
We\'ve been working on a ruby project involving users, private messages and any kind of network based related features.

We've been working on a ruby project involving users, private messages and any kind of network based related features.

We already have some preferences system that allow users to describe their self. Hair color, wear-style, height, weight, shape, hobbies, etc.

We face the fact that some option list (content of combo box) need to be edited by admin user and translated in many languages (we already use the classic's yml support for i18n in Rails 3).

The ad开发者_如何学编程mins, want to add users descriptions.

For instance imagine you have a user model with : date of birth, Current city, mail, username

We already have everything ready with has_many and related tables named preferences. We use a seed that contain :

hair_style :

  • long
  • short
  • semi-long

hair_color :

  • red
  • white
  • brown
  • black
  • blond

eye_colors : - brown - green - yellow - blue

Now, the administrator want to add pink to the hair color and gray to the eye_colors property. Also he wants this to preferences/descriptions to be well translated for french users and so he need to translate them.

To summarize we have two issues :

  • on-the-fly and non-model bind descriptions preferences (we know the list is going to get larger and larger has many idea will pop up)
  • translation of this descriptions as we can not use yml files here.

We'll be happy to hear from you ! hope someone will guide us.

P.S : already read this : Best approach to save user preferences?

Rails: How do I model preferences? Should I use has_many :through?

and found that :

https://github.com/pluginaweek/preferences https://github.com/huacnlee/rails-settings-cached

I've also found that one : http://code.lancepollard.com/posts/the-missing-rails-key-value-gem

and was wondering if it would be intersting to get inspiration from it.

I've also read this : http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002284

And found that one : http://blog.project-sierra.de/archives/1379

But I'm wondering how to be able to create dynamically the user preferences ?

0

精彩评论

暂无评论...
验证码 换一张
取 消