Closed wanze closed 9 years ago
Awesome! UI chief|
There is a nil excpetion:
NoMethodError in Achievements#index
Showing /home/lexruee/workspace/ASE/CyberCoachApp/app/views/achievements/index.html.erb where line #22 raised:
undefined method `type' for nil:NilClass
Extracted source (around line #22):
19 <td><%= achievement.points %></td>
20 <td><%= achievement.sport %></td>
21 <td><%= achievement.rules %></td>
22 <td><%= achievement.validator.type %></td>
23 <td><%= link_to 'Show', achievement %></td>
24 <td><%= link_to 'Edit', edit_achievement_path(achievement) %></td>
25 <td><%= link_to 'Destroy', achievement, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Rails.root: /home/lexruee/workspace/ASE/CyberCoachApp
@lexruee
Argh you don't have the attribute validator in the database, sorry.
I've put it into the seed file here: https://github.com/Bergrebell/CyberCoach/blob/dev/db/seeds.rb
Should be okay if you seed the database
rake db:seed
@svetakrasikova @Bergrebell You need to execute the command above too in order to make the achievements work
I close this one, we need to think about seeding the db when we deploy!
So finally the AttributeValidator is working. I've created some achievements locally for testing, here are some screenshots:
/public/images/achievement_icons/
folder for some examples.How to create an achievement:
http://localhost:3000/achievements
Rules are written as JSON string. Every attribute from the results object and the sport_session object is available. Also there is a special attribute
n_participants
holding the number of participants that were joining the session.Here are some samples to get you started, multiple rules are evaluated with AND:
[ {"operator" : ">", "attribute" : "length", "value" : "5"} ]
[ {"operator" : ">", "attribute" : "length", "value" : "10"}, {"operator" : "<", "attribute" : "time", "value" : "60"} ]
As you probably notice, we will need to define the units for each attribute!
Cheers and enjoy the weekend