Skip to content
Ruby HTML CSS JavaScript CoffeeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
db
lib
log
public
test
vendor/assets
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru

README.md

gioco sample

Create rails ap and initialize gioco.

rails new a
cd a
echo "gem 'gioco'" >> Gemfile
bundle install
rails generate scaffold user name:string
bundle exec rake db:migrate
rails g gioco:setup --points --kinds

Prepare badges

bundle exec rake 'gioco:add_badge[good  ,         5, grade, 1 ]'
bundle exec rake 'gioco:add_badge[great ,        10, grade, 1 ]'
bundle exec rake 'gioco:add_badge[super great ,  50, grade, 1 ]'
bundle exec rake 'gioco:add_badge[fever       , 100, grade, 1 ]'

Test the badge by achieving speicfic point

% rails console
> user = User.new
> user.name = 'matsu'
> user.save()
> kind_id = Kind.where('name = ? ', 'grade').pluck(:id).pop
> user.change_points({
  points:1,
  kind: kind_id
})
> user.next_badge?()
> user.change_points({
  points: 10,
  kind: kind_id
})
> user.badges
> user.points

Test ranking

% rails console
> Gioco::Ranking.generate
You can’t perform that action at this time.