Skip to content

Commit

Permalink
using formtastic
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Dec 27, 2010
1 parent 54c467d commit a640773
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 30 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -34,3 +34,5 @@ gem "cucumber-rails", :group => :test
gem "capybara", :group => :test
gem "haml", ">= 3.0.0"
gem "haml-rails"

gem "formtastic"
5 changes: 5 additions & 0 deletions Gemfile.lock
Expand Up @@ -56,6 +56,10 @@ GEM
abstract (>= 1.0.0)
ffi (0.6.3)
rake (>= 0.8.7)
formtastic (1.1.0)
actionpack (>= 2.3.0)
activesupport (>= 2.3.0)
i18n (>= 0.4.0)
gherkin (2.3.3)
json (~> 1.4.6)
haml (3.0.25)
Expand Down Expand Up @@ -127,6 +131,7 @@ PLATFORMS
DEPENDENCIES
capybara
cucumber-rails
formtastic
haml (>= 3.0.0)
haml-rails
rails (= 3.0.3)
Expand Down
18 changes: 0 additions & 18 deletions app/controllers/participation_controller.rb

This file was deleted.

18 changes: 18 additions & 0 deletions app/controllers/participations_controller.rb
@@ -0,0 +1,18 @@
class ParticipationsController < ApplicationController
def index
Participation.new.deployed!(user_id, ENV)
end

def update
Participation.new(params[:participation]).announce!(user_id, ENV)
redirect_to :action => "done"
end

def done
end

protected
def user_id
session[:user_id] ||= Time.now.to_s
end
end
2 changes: 2 additions & 0 deletions app/helpers/participations_helper.rb
@@ -0,0 +1,2 @@
module ParticipationsHelper
end
19 changes: 17 additions & 2 deletions app/models/participation.rb
@@ -1,9 +1,24 @@
class Participation
def self.deployed!(user_id, env)
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming

attr_accessor :name
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end

def persisted?
false
end

def deployed!(user_id, env)
# TODO - announce "deployed" to central server
end

def self.announce!(user_id, env, participation)
def announce!(user_id, env)
# TODO - announce "submitted" to central server
end
end
7 changes: 0 additions & 7 deletions app/views/participation/index.html.haml

This file was deleted.

File renamed without changes.
10 changes: 10 additions & 0 deletions app/views/participations/index.html.haml
@@ -0,0 +1,10 @@
- content_for :section_title do
Deployed!

- semantic_form_for(Participation.new) do |f|
- f.inputs :name => 'Information' do
= f.input :name, :label => 'Your names'

- f.buttons do
= f.commit_button 'Submit'

7 changes: 4 additions & 3 deletions config/routes.rb
@@ -1,7 +1,8 @@
DemoDayApp::Application.routes.draw do
root :to => "participation#index"
get "participation/index"
post "participation/update"
resources :participations

root :to => "participations#index"

get "participation/done"

# The priority is based upon order of creation:
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/participations_controller_spec.rb
@@ -0,0 +1,5 @@
require 'spec_helper'

describe ParticipationsController do

end
15 changes: 15 additions & 0 deletions spec/helpers/participations_helper_spec.rb
@@ -0,0 +1,15 @@
require 'spec_helper'

# Specs in this file have access to a helper object that includes
# the ParticipationsHelper. For example:
#
# describe ParticipationsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe ParticipationsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit a640773

Please sign in to comment.