-
Notifications
You must be signed in to change notification settings - Fork 197
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
Different Types of Badges #28
Comments
Interesting question. Tried subclassing require 'ambry'
require 'ambry/active_model'
class MyAppBadge < Badge
extend Ambry::Model
extend Ambry::ActiveModel
field :type
end
Badge.new.attributes # => {"id"=>nil, "name"=>nil, "level"=>nil, "image"=>nil, "description"=>nil}
MyAppBadge.new.attributes # => {"type"=>nil} @norman, do you think an Ambry model should be extendable like this? |
Meanwhile, this seems to work: require 'ambry'
require 'ambry/active_model'
class MyAppBadge < Badge
extend Ambry::Model
extend Ambry::ActiveModel
field *Badge.new.attributes.keys, :type
end
Badge.new.attributes.keys # => {"id"=>nil, "name"=>nil, "level"=>nil, "image"=>nil, "description"=>nil}
MyAppBadge.new.attributes # => {"id"=>nil, "name"=>nil, "level"=>nil, "image"=>nil, "description"=>nil, "type"=>nil} |
This makes sense. Thanks for trying it out. |
Thanks for your feedback! |
Would this be the way to group/indicate badges that are harder to get? For instance, Stack Overflow's badge system has Gold, Silver and Bronze badges. Gold are rare and require quite a bit more work to get and Bronze are the easiest. |
If you don't use the |
Now fixed in merit master as of 97c998f |
My project needed different types of badges like Foursquare's: Foursquare, Expertise and Partner badges. Some would have levels, some would not. It's probably a matter of adding a field called type to the Badge model.
Is there a better way of adding fields to the model other than having them coded into the gem? Not too sure about the ambry gem but could it be possible to extend the Badge class and just add the fields there?
The text was updated successfully, but these errors were encountered: