Skip to content

Commit 79c2707

Browse files
committed
Adding basic programs stuff
1 parent 7d8edf2 commit 79c2707

21 files changed

Lines changed: 349 additions & 3 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Api::ProgramsController < InheritedResources::Base
2+
end

app/helpers/api/programs_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module Api::ProgramsHelper
2+
end

app/models/program.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Program
2+
include MongoMapper::Document
3+
4+
key :author_username, String
5+
key :slug, String
6+
key :title, String
7+
key :source_code, String
8+
9+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- content_for :title do
2+
= "Editing #{resource}"
3+
4+
= render 'form'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- title "All Programs"
2+
3+
%p Here's a list of all of the programs we have:
4+
5+
%ul
6+
- @programs.each do |program|
7+
%li= link_to "#{program.author_username}/#{program.slug}", program
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
= simple_form_for(resource, :url => @form_url) do |f|
2+
= f.error_notification
3+
4+
.inputs
5+
= f.input :author_username
6+
= f.input :slug
7+
= f.input :title
8+
= f.input :source_code, :as => :text
9+
10+
.actions
11+
= f.button :submit
12+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- title @program.title
2+
3+
%p= @program.title
4+
%p By #{@program.author_username}
5+
6+
%p= link_to "Back to list of all programs", programs_path, :rel => "/rels/program-index"
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
= title "Welcome"
22

3-
%p!= "For a list of the relations we've defined for this API, go " + link_to("here", rels_path, :rel => "/rels/rel-index")
4-
%p!= "You can find the latest released version of Hackety Hack " + link_to("here", newest_version_path, :rel => "/rels/current-application-version") + "."
3+
%p For a list of the relations we've defined for this API, go #{link_to("here", rels_path, :rel => "/rels/rel-index")}.
4+
%p You can find the latest released version of Hackety Hack #{link_to("here", newest_version_path, :rel => "/rels/current-application-version")}.
5+
6+
%h2 Programs
7+
8+
%p For a list of programs our users have made, go #{link_to("here", programs_path, :rel => "/rels/program-index")}.
9+
%p To make a new program, you can find a form #{link_to("here", new_program_path, :rel => "/rels/program-new")}.
510

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
match '/versions/newest' => 'static#newest_version', :as => "newest_version"
88
scope :module => "Api" do
99
resources :rels, :only => [:index, :show]
10+
resources :programs
1011
end
1112
end
1213

db/schema.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 0) do
14+
ActiveRecord::Schema.define(:version => 20110830001940) do
15+
16+
create_table "questions", :force => true do |t|
17+
t.string "title"
18+
t.text "description"
19+
t.integer "user_id"
20+
t.datetime "created_at"
21+
t.datetime "updated_at"
22+
end
1523

1624
end

0 commit comments

Comments
 (0)