Gioco gamification gem

I am trying to use Gamification Gioco Gem. I was able to install the Gem. However when I am trying to create a badge, I am getting the following error. It appears as I go deeper that it is failing on

kind = Kind.find_or_create_by(name: 'hr') in the gioco.rake.rb 

Here is the full log with more details

rake --trace gioco:add_badge[explorer,0,hr,true]
** Invoke gioco:add_badge (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute gioco:add_badge

rake aborted! 
undefined method `find_or_create_by' for #<Class:0x007ff9546bb778>
/Users/satya/gamification/gameclient/lib/tasks/gioco.rake:36:in `eval'
(eval):1:in `block (2 levels) in <top (required)>'
/Users/satya/gamification/gameclient/lib/tasks/gioco.rake:36:in `eval'
/Users/satya/gamification/gameclient/lib/tasks/gioco.rake:36:in `block (2 levels) in <top    (required)>'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/satya/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/Users/satya/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'

I am using rails 3.2.16. I am wondering if others have used it in Rails 3.x environment.

Thanks Satya


It appears that find_or_create_by is no longer supported by Rails 3.2.

The recommended approach for Rails 3.2 is to use first_or_create, first_or_create!, first_or_initialize methods. So changing the code from

badge_string = "kind = Kind.find_or_create_by(name: '#{args.kind}').first_or_create! \n"


badge_string = "kind = Kind.where(name: '#{args.kind}').first_or_create! \n"

overcomes this problem. However a note to Gioco Gem users, there seems to be a few issues with its setup scripts. Ids for points, badges, levels are not created and you will get a mass_assignment error as well. Not sure if this gem is actively supported.

Need Your Help

Better template language needed

java templates velocity freemarker stringtemplate

Yes, I know that this has been asked before. But most of the questions were two years ago, and there's got to be a better answer today.

Assigning Roles with MVC SimpleMembership

c# membership-provider

I am trying out "SimpleMembership" in MVC3 via Nuget and have downloaded the sample to play with.