Skip to content

Commit

Permalink
home page is a dynamic list of forms
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Feb 25, 2010
1 parent 829f5f0 commit 81a80eb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
4 changes: 4 additions & 0 deletions app/controllers/operate_form_controller.rb
@@ -1,4 +1,8 @@
class OperateFormController < ApplicationController
def index
@forms = GoogleForm.all
end

def show
slug = params[:slug].first
if @google_form = GoogleForm.find_by_slug(slug)
Expand Down
4 changes: 4 additions & 0 deletions app/models/google_form.rb
Expand Up @@ -4,6 +4,10 @@ class GoogleForm < ActiveRecord::Base
before_create :clean_formkey
before_create :validate_formkey_is_valid

def title
slug
end

def fetch_form_page
uri = URI.parse("http://spreadsheets.google.com/viewform?formkey=#{formkey}")
req = Net::HTTP::Get.new("#{uri.path}?#{uri.query}")
Expand Down
13 changes: 0 additions & 13 deletions app/views/home/index.html.haml

This file was deleted.

9 changes: 9 additions & 0 deletions app/views/operate_form/index.html.haml
@@ -0,0 +1,9 @@
/ Home
#home
%h2 Our forms

%ul
- for form in @forms
%li= link_to form.title, "/#{form.slug}"


8 changes: 5 additions & 3 deletions config/routes.rb
@@ -1,9 +1,11 @@
ActionController::Routing::Routes.draw do |map|
map.resources :google_forms

map.root :controller => 'home', :action => 'index'
map.with_options :controller => 'operate_form' do |f|
f.root :action => 'index'
f.submit_operate_form "operate_form/:id", :action => "update"
f.catch_all "*slug", :controller => "operate_form", :action => "show"
end

map.submit_operate_form "operate_form/:id", :controller => "operate_form", :action => "update"
map.catch_all "*slug", :controller => "operate_form", :action => "show"

end

0 comments on commit 81a80eb

Please sign in to comment.