Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Ability to add other fields to badge definition #77

Closed
rmccown opened this issue Apr 23, 2013 · 6 comments
Closed

Feature Request: Ability to add other fields to badge definition #77

rmccown opened this issue Apr 23, 2013 · 6 comments

Comments

@rmccown
Copy link
Contributor

rmccown commented Apr 23, 2013

Howdy
I'd like to request the ability to add other optional fields to the badge definition in the merit.rb file. Something like this:

Merit::Badge.create!({
:id=> 7,
:name=>'6 Months Active',
:image=>'badges/6months.png',
:description=>'Users that are active after six months',
:my_other_field=>"foo",
:my_other_field2=>"bar"
})

etc...

@tute
Copy link
Member

tute commented Apr 23, 2013

This was discussed in: #28 (comment)

May I ask how would you use custom fields?

@tute tute closed this as completed Apr 23, 2013
@rmccown
Copy link
Contributor Author

rmccown commented Apr 23, 2013

A couple of ways. Our app will probably end up with fifty or more badges a user can earn. We'd like the ability to group them, sort them, and make them visible/active or not. So initially we have discussed needing:

:order=>
:group=>
:visible=>

flags. Granted, I could make my own badge_attribute table and link it over to Merit::Badge by badge ID, but that's not really clean.

Thanks
-=Bob

@tute
Copy link
Member

tute commented Apr 23, 2013

I'm thinking of getting rid of the level attribute. I'm interested in your thoughts of that. If you wouldn't use it as merit intends right now, you may use it as 'group'.

I'll think about the other ones.

@rmccown
Copy link
Contributor Author

rmccown commented Apr 23, 2013

We're not currently using level, and anything that needs a different level of activity, we're tracking ourselves (log-ins,score, etc). Maybe sub-classing ourselves is the right way to go about this

@tute
Copy link
Member

tute commented Apr 23, 2013

Merit::Badge uses ambry, and ambry allows hashes as attributes. In that case, a custom_fields_hash (or similarly named) attribute in the Badge model would allow applications to extend badges however they want. PRs welcome. :-)

@tute tute reopened this Apr 23, 2013
@rmccown
Copy link
Contributor Author

rmccown commented Apr 23, 2013

Yes, a custom fields hash would be a great way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants