Permalink
Browse files

Basic tasks index and show view.

  • Loading branch information...
1 parent 7e4ff9e commit 5cd3c1f549ea8a4acdb191acabad1dc4a1160c8a @pascalr committed May 8, 2012
View
@@ -6,6 +6,7 @@ gem 'rails', '3.1.3'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
+gem 'ruby-debug19'
gem 'haml-rails'
gem "recaptcha", :require => "recaptcha/rails"
gem 'bcrypt-ruby', :require => 'bcrypt'
View
@@ -30,6 +30,7 @@ GEM
activesupport (3.1.3)
multi_json (~> 1.0)
ansi (1.4.2)
+ archive-tar-minitar (0.5.2)
arel (2.2.3)
bcrypt-ruby (3.0.1)
builder (3.0.0)
@@ -40,6 +41,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.1)
+ columnize (0.3.6)
erubis (2.7.0)
execjs (1.3.2)
multi_json (~> 1.0)
@@ -55,6 +57,8 @@ GEM
railties (~> 3.0)
thor (~> 0.14)
json (1.7.1)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -91,6 +95,16 @@ GEM
rdoc (3.12)
json (~> 1.4)
recaptcha (0.3.4)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
sass (3.1.17)
sass-rails (3.1.6)
actionpack (~> 3.1.0)
@@ -124,6 +138,7 @@ DEPENDENCIES
pg
rails (= 3.1.3)
recaptcha
+ ruby-debug19
sass-rails (~> 3.1.5)
turn (= 0.8.2)
uglifier (>= 1.0.3)
@@ -4,4 +4,4 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
-*/
+*/
@@ -22,10 +22,10 @@
width: 400px;
border: 2px solid #CF0000;
padding: 0px;
- padding-bottom: 12px;
- margin-bottom: 20px;
+ padding-bottom: 3px;
+ margin-bottom: 8px;
background-color: #f0f0f0;
- font-size: 12px;
+ font-size: 14px;
}
.error_messages h2 {
@@ -0,0 +1,36 @@
+class TasksController < ApplicationController
+
+ def index
+ @tasks = Task.all
+ end
+
+ def show
+ @task = Task.find(params[:id])
+ end
+
+ def create
+ @task = Task.new(params[:task])
+ if @task.save
+ redirect_to @task, notice: 'Task was successfully created.'
+ else
+ redirect_to controller: :tasks, action: :index, task: params[:task], task_errors: @task.errors.full_messages
+ end
+ end
+
+ def update
+ @task = Task.find(params[:id])
+
+ if @task.update_attributes(params[:task])
+ redirect_to @task, notice: 'Task was successfully updated.'
+ else
+ redirect_to controller: :tasks, action: :show, id: @task.id, task: params[:task], task_errors: @task.errors.full_messages
+ end
+ end
+
+ def destroy
+ @task = Task.find(params[:id])
+ @task.destroy
+
+ redirect_to tasks_url
+ end
+end
@@ -0,0 +1,2 @@
+module TasksHelper
+end
View
@@ -0,0 +1,8 @@
+class Task < ActiveRecord::Base
+ validates_presence_of :name
+ validates_length_of :name, :minimum => 15, :maximum => 150
+
+
+ validates_presence_of :description
+ validates_length_of :description, :minimum => 40, :maximum => 1200
+end
@@ -19,6 +19,9 @@
<%- end %>
</div>
<div id="core">
+ <%= yield :core_header %>
+ <%= content_tag :div, flash[:notice], :id => "flashnotice" if flash[:notice] %>
+ <%= content_tag :div, flash[:alert], :id => "flashalert" if flash[:alert] %>
<%= yield %>
</div>
</div>
@@ -0,0 +1,4 @@
+<%- content_for :core_header do %>
+ <h1><%= link_to "Involved sponsors", tasks_path %></h1>
+<%- end %>
+<%= render :template => 'layouts/application' %>
@@ -0,0 +1,15 @@
+- task = params.has_key?(:task) ? Task.new(params[:task]) : Task.new
+= form_for task do |f|
+ -if params.has_key?(:task_errors)
+ #error_explanation
+ - params[:task_errors].each do |msg|
+ .error_messages= msg
+
+ .field
+ = f.label :name
+ .name_text_field= f.text_field :name
+ .field
+ = f.label :description
+ .name_text_area= f.text_area :description
+ .actions
+ = f.submit 'Propose task'
@@ -0,0 +1,2 @@
+<div class="task_name"><%= link_to task.name, task %></div>
+<div class="task_description"><%= task.description %></div>
@@ -0,0 +1,2 @@
+<%= render partial: @tasks %>
+<%= render partial: "tasks/form" %>
@@ -0,0 +1,2 @@
+<h2><%= @task.name %></h2>
+<p><%= @task.description %></p>
View
@@ -1,5 +1,8 @@
InvolvedSponsors::Application.routes.draw do
- root :to => 'home#index'
+
+ resources :tasks, :except => [:new]
+
+ root :to => 'tasks#index'
get "log_in" => "sessions#new", :as => "log_in"
get "log_out" => "sessions#destroy", :as => "log_out"
@@ -0,0 +1,12 @@
+class CreateTasks < ActiveRecord::Migration
+ def change
+ create_table :tasks do |t|
+ t.string :name
+ t.text :description
+ t.float :rank
+ t.boolean :accepted
+
+ t.timestamps
+ end
+ end
+end
View
@@ -11,7 +11,16 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120508152049) do
+ActiveRecord::Schema.define(:version => 20120508163245) do
+
+ create_table "tasks", :force => true do |t|
+ t.string "name"
+ t.text "description"
+ t.float "rank"
+ t.boolean "accepted"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
create_table "users", :force => true do |t|
t.string "email"

0 comments on commit 5cd3c1f

Please sign in to comment.