Permalink
Browse files

achievements first commit

  • Loading branch information...
1 parent 63da929 commit 6e63be50273c8245dade44a2221b27054d5587e9 @nov committed Sep 27, 2011
View
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
-gem 'rake', '0.8.7'
+gem 'rake'
gem 'rails', '3.0.6'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'fb_graph'
View
@@ -33,23 +33,23 @@ GEM
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
- fb_graph (2.1.6)
+ fb_graph (2.1.7)
httpclient (>= 2.2.0.2)
rack-oauth2 (>= 0.9.4)
httpclient (2.2.1)
i18n (0.5.0)
- json (1.6.0)
+ json (1.6.1)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
polyglot (0.3.2)
- rack (1.2.3)
+ rack (1.2.4)
rack-mount (0.6.14)
rack (>= 1.0.0)
- rack-oauth2 (0.10.1)
+ rack-oauth2 (0.11.0)
activesupport (>= 2.3)
attr_required (>= 0.0.3)
httpclient (>= 2.2.0.2)
@@ -71,7 +71,7 @@ GEM
activesupport (= 3.0.6)
rake (>= 0.8.7)
thor (~> 0.14.4)
- rake (0.8.7)
+ rake (0.9.2)
sqlite3 (1.3.4)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
@@ -87,5 +87,5 @@ PLATFORMS
DEPENDENCIES
fb_graph
rails (= 3.0.6)
- rake (= 0.8.7)
+ rake
sqlite3-ruby
@@ -0,0 +1,24 @@
+class AchievementsController < ApplicationController
+ before_filter :require_authentication, :except => :show
+
+ def index
+ @achievements = Achievement.all
+ end
+
+ def show
+ @achievement = Achievement.find params[:id]
+ end
+
+ def new
+ @achievement = Achievement.new
+ end
+
+ def create
+ @achievement = Achievement.new params[:achievement]
+ if @achievement.save
+ redirect_to achievement_url(@achievement)
+ else
+ render :new
+ end
+ end
+end
@@ -0,0 +1,4 @@
+class Achievement < ActiveRecord::Base
+ validates :title, :description, :image_url, :presence => true
+ validates :points, :presence => true, :inclusion => {:in => 1..100}
+end
@@ -0,0 +1,11 @@
+<article>
+ <h2>Achievements</h2>
+ <ul>
+ <% @achievements.each do |achievement| %>
+ <li><%= link_to achievement.title, achievement_path(achievement) %></li>
+ <% end %>
+ </ul>
+ <nav>
+ <%= link_to 'Register new one', new_achievement_path %>
+ </nav>
+</article>
@@ -0,0 +1,19 @@
+<%= form_for @achievement do |f| %>
+ <div>
+ <%= f.label :title %>
+ <%= f.text_field :title %>
+ </div>
+ <div>
+ <%= f.label :description %>
+ <%= f.text_field :description %>
+ </div>
+ <div>
+ <%= f.label :image_url, 'Image URL' %>
+ <%= f.url_field :image_url %>
+ </div>
+ <div>
+ <%= f.label :points, 'Points (0-100)' %>
+ <%= f.number_field :points %>
+ </div>
+ <%= f.submit %>
+<% end %>
@@ -0,0 +1,15 @@
+<% content_for :head do %>
+ <meta property="og:title" content="<%= @achievement.title %>">
+ <meta property="og:description" content="<%= @achievement.description %>">
+ <meta property="og:type" content="game.achievement">
+ <meta property="og:url" content="<%= achievement_url(@achievement) %>">
+ <meta property="og:image" content="<%= @achievement.image_url %>">
+ <meta property="og:points" content="<%= @achievement.points %>">
+
+<% end %>
+
+<article>
+ <h2><%= @achievement.title %> - <%= @achievement.points %> [pts]</h2>
+ <p><%= @achievement.description %></p>
+ <%= image_tag @achievement.image_url %>
+</article>
@@ -10,6 +10,7 @@
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<%= javascript_include_tag 'rails', 'jquery.gritter' %>
<%= csrf_meta_tag %>
+ <%= yield :head %>
</head>
<body>
<div id="fb-root"></div>
View
@@ -2,6 +2,7 @@
# Canvas App
resource :canvas, :only => [:show, :create]
resource :credit, :only => :create
+ resources :achievements, :only => [:index, :show, :new, :create]
# Connect Site
resource :facebook, :except => :create do
@@ -0,0 +1,13 @@
+class CreateAchievements < ActiveRecord::Migration
+ def self.up
+ create_table :achievements do |t|
+ t.string :title, :description, :image_url
+ t.integer :points
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :achievements
+ end
+end
View
@@ -10,7 +10,16 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110623075710) do
+ActiveRecord::Schema.define(:version => 20110927070839) do
+
+ create_table "achievements", :force => true do |t|
+ t.string "title"
+ t.string "description"
+ t.string "image_url"
+ t.integer "points"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
create_table "facebooks", :force => true do |t|
t.string "identifier", :limit => 20
@@ -0,0 +1,11 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class AchievementsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class AchievementTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end

0 comments on commit 6e63be5

Please sign in to comment.