From 3eeec89776c34c2bae9c92a891a470ea1f0fce05 Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 21 May 2012 22:40:26 -0500 Subject: [PATCH 01/19] initial local commit --- Gemfile | 10 ++++- Gemfile.lock | 68 +++++++++++++++++------------ config/application.rb | 2 +- config/initializers/secret_token.rb | 2 +- config/routes.rb | 2 + 5 files changed, 53 insertions(+), 31 deletions(-) diff --git a/Gemfile b/Gemfile index 668ed5c..ab4e34b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,10 @@ source 'https://rubygems.org' -gem 'rails', '3.2.2' +gem 'rails', '3.2.3' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + gem 'sqlite3' @@ -8,10 +12,12 @@ gem 'sqlite3' # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer' + # gem 'therubyracer', :platform => :ruby + gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 05ba48f..19c3296 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,36 +1,45 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.2) - actionpack (= 3.2.2) - mail (~> 2.4.0) - actionpack (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + actionmailer (3.2.3) + actionpack (= 3.2.3) + mail (~> 2.4.4) + actionpack (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) - rack-cache (~> 1.1) + rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) - activemodel (3.2.2) - activesupport (= 3.2.2) + activemodel (3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) - activerecord (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + activerecord (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) - activesupport (3.2.2) + activeresource (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) + activesupport (3.2.3) i18n (~> 0.6) multi_json (~> 1.0) arel (3.0.2) builder (3.0.0) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.3.3) erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) hike (1.2.1) i18n (0.6.0) journey (1.0.3) @@ -52,17 +61,17 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.2.2) - actionmailer (= 3.2.2) - actionpack (= 3.2.2) - activerecord (= 3.2.2) - activeresource (= 3.2.2) - activesupport (= 3.2.2) + rails (3.2.3) + actionmailer (= 3.2.3) + actionpack (= 3.2.3) + activerecord (= 3.2.3) + activeresource (= 3.2.3) + activesupport (= 3.2.3) bundler (~> 1.0) - railties (= 3.2.2) - railties (3.2.2) - actionpack (= 3.2.2) - activesupport (= 3.2.2) + railties (= 3.2.3) + railties (3.2.3) + actionpack (= 3.2.3) + activesupport (= 3.2.3) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -86,12 +95,17 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.33) + uglifier (1.2.4) + execjs (>= 0.3.0) + multi_json (>= 1.0.2) PLATFORMS ruby DEPENDENCIES + coffee-rails (~> 3.2.1) jquery-rails - rails (= 3.2.2) + rails (= 3.2.3) sass-rails (~> 3.2.3) sqlite3 + uglifier (>= 1.0.3) diff --git a/config/application.rb b/config/application.rb index a98863a..9d819a9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -48,7 +48,7 @@ class Application < Rails::Application # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true + config.active_record.whitelist_attributes = true # Enable the asset pipeline config.assets.enabled = true diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index ebec1a5..b72aae5 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -WhosGotWhat::Application.config.secret_token = '2a1d27ceb470db8eca79d7f47d1abd4094c287c3caf76a2736dc68af75879899e6662e895f076edfc7daa5048f2e1f0db47847c2b0aed007dd8ca0791c3f8abf' +WhosGotWhat::Application.config.secret_token = 'd8ccc235cfc7b387d0a5b41a7833a8905e01676aae8f38b28b9aea6d43e4d7e2ec8aa06da3622ffa6987e78cbab66c5aebaa7231cdf842cc3663310c047335f1' diff --git a/config/routes.rb b/config/routes.rb index d7527d9..ff9ca4b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ WhosGotWhat::Application.routes.draw do + resources :tools + # The priority is based upon order of creation: # first created -> highest priority. From 468cb6e8b5d3b493ed1ffc349e21c9556e0f99e7 Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 4 Jun 2012 23:03:09 -0500 Subject: [PATCH 02/19] Added tool fields --- .project | 18 ++++ app/assets/stylesheets/scaffolds.css.scss | 56 +++++++++++++ app/assets/stylesheets/tools.css.scss | 3 + app/controllers/tools_controller.rb | 83 +++++++++++++++++++ app/helpers/tools_helper.rb | 2 + app/models/tool.rb | 4 + app/views/tools/_form.html.erb | 27 ++++++ app/views/tools/edit.html.erb | 6 ++ app/views/tools/index.html.erb | 21 +++++ app/views/tools/new.html.erb | 5 ++ app/views/tools/show.html.erb | 5 ++ db/migrate/20120522025027_create_tools.rb | 11 +++ .../20120605030001_add_owner_to_tools.rb | 10 +++ db/schema.rb | 25 ++++++ test/fixtures/tools.yml | 11 +++ test/functional/tools_controller_test.rb | 49 +++++++++++ test/unit/helpers/tools_helper_test.rb | 4 + test/unit/tool_test.rb | 7 ++ 18 files changed, 347 insertions(+) create mode 100644 .project create mode 100644 app/assets/stylesheets/scaffolds.css.scss create mode 100644 app/assets/stylesheets/tools.css.scss create mode 100644 app/controllers/tools_controller.rb create mode 100644 app/helpers/tools_helper.rb create mode 100644 app/models/tool.rb create mode 100644 app/views/tools/_form.html.erb create mode 100644 app/views/tools/edit.html.erb create mode 100644 app/views/tools/index.html.erb create mode 100644 app/views/tools/new.html.erb create mode 100644 app/views/tools/show.html.erb create mode 100644 db/migrate/20120522025027_create_tools.rb create mode 100644 db/migrate/20120605030001_add_owner_to_tools.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/tools.yml create mode 100644 test/functional/tools_controller_test.rb create mode 100644 test/unit/helpers/tools_helper_test.rb create mode 100644 test/unit/tool_test.rb diff --git a/.project b/.project new file mode 100644 index 0000000..9bd42ac --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + WhosGotWhat + + + + + + com.aptana.ide.core.unifiedBuilder + + + + + + org.radrails.rails.core.railsnature + com.aptana.ruby.core.rubynature + + diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 0000000..05188f0 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,56 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; } + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; } + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; } + +a { + color: #000; + &:visited { + color: #666; } + &:hover { + color: #fff; + background-color: #000; } } + +div { + &.field, &.actions { + margin-bottom: 10px; } } + +#notice { + color: green; } + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; } + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; } + ul li { + font-size: 12px; + list-style: square; } } diff --git a/app/assets/stylesheets/tools.css.scss b/app/assets/stylesheets/tools.css.scss new file mode 100644 index 0000000..1c54797 --- /dev/null +++ b/app/assets/stylesheets/tools.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the tools controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/tools_controller.rb b/app/controllers/tools_controller.rb new file mode 100644 index 0000000..a0a34ad --- /dev/null +++ b/app/controllers/tools_controller.rb @@ -0,0 +1,83 @@ +class ToolsController < ApplicationController + # GET /tools + # GET /tools.json + def index + @tools = Tool.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @tools } + end + end + + # GET /tools/1 + # GET /tools/1.json + def show + @tool = Tool.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @tool } + end + end + + # GET /tools/new + # GET /tools/new.json + def new + @tool = Tool.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @tool } + end + end + + # GET /tools/1/edit + def edit + @tool = Tool.find(params[:id]) + end + + # POST /tools + # POST /tools.json + def create + @tool = Tool.new(params[:tool]) + + respond_to do |format| + if @tool.save + format.html { redirect_to @tool, notice: 'Tool was successfully created.' } + format.json { render json: @tool, status: :created, location: @tool } + else + format.html { render action: "new" } + format.json { render json: @tool.errors, status: :unprocessable_entity } + end + end + end + + # PUT /tools/1 + # PUT /tools/1.json + def update + @tool = Tool.find(params[:id]) + + respond_to do |format| + if @tool.update_attributes(params[:tool]) + format.html { redirect_to @tool, notice: 'Tool was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @tool.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /tools/1 + # DELETE /tools/1.json + def destroy + @tool = Tool.find(params[:id]) + @tool.destroy + + respond_to do |format| + format.html { redirect_to tools_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/tools_helper.rb b/app/helpers/tools_helper.rb new file mode 100644 index 0000000..6f87959 --- /dev/null +++ b/app/helpers/tools_helper.rb @@ -0,0 +1,2 @@ +module ToolsHelper +end diff --git a/app/models/tool.rb b/app/models/tool.rb new file mode 100644 index 0000000..6046ad0 --- /dev/null +++ b/app/models/tool.rb @@ -0,0 +1,4 @@ +class Tool < ActiveRecord::Base + # attr_accessible :title, :body + # testing +end diff --git a/app/views/tools/_form.html.erb b/app/views/tools/_form.html.erb new file mode 100644 index 0000000..cbf2a19 --- /dev/null +++ b/app/views/tools/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_for(@tool) do |f| %> + <% if @tool.errors.any? %> +
+

<%= pluralize(@tool.errors.count, "error") %> prohibited this tool from being saved:

+ +
    + <% @tool.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + + <%= f.label :name %>: + <%= f.text_field :name %>
+ + <%= f.check_box :electric %>
+ + <%= f.label :volts %>: + <%= f.text_field :volts %>
+ + + +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/tools/edit.html.erb b/app/views/tools/edit.html.erb new file mode 100644 index 0000000..49cdd83 --- /dev/null +++ b/app/views/tools/edit.html.erb @@ -0,0 +1,6 @@ +

Editing tool

+ +<%= render 'form' %> + +<%= link_to 'Show', @tool %> | +<%= link_to 'Back', tools_path %> diff --git a/app/views/tools/index.html.erb b/app/views/tools/index.html.erb new file mode 100644 index 0000000..d7f9b96 --- /dev/null +++ b/app/views/tools/index.html.erb @@ -0,0 +1,21 @@ +

Listing tools

+ + + + + + + + +<% @tools.each do |tool| %> + + + + + +<% end %> +
<%= link_to 'Show', tool %><%= link_to 'Edit', edit_tool_path(tool) %><%= link_to 'Destroy', tool, confirm: 'Are you sure?', method: :delete %>
+ +
+ +<%= link_to 'New Tool', new_tool_path %> diff --git a/app/views/tools/new.html.erb b/app/views/tools/new.html.erb new file mode 100644 index 0000000..79a5e74 --- /dev/null +++ b/app/views/tools/new.html.erb @@ -0,0 +1,5 @@ +

New tool

+ +<%= render 'form' %> + +<%= link_to 'Back', tools_path %> diff --git a/app/views/tools/show.html.erb b/app/views/tools/show.html.erb new file mode 100644 index 0000000..d164fdd --- /dev/null +++ b/app/views/tools/show.html.erb @@ -0,0 +1,5 @@ +

<%= notice %>

+ + +<%= link_to 'Edit', edit_tool_path(@tool) %> | +<%= link_to 'Back', tools_path %> diff --git a/db/migrate/20120522025027_create_tools.rb b/db/migrate/20120522025027_create_tools.rb new file mode 100644 index 0000000..df8e437 --- /dev/null +++ b/db/migrate/20120522025027_create_tools.rb @@ -0,0 +1,11 @@ +class CreateTools < ActiveRecord::Migration + def change + create_table :tools do |t| + t.string :name, :null => false, :limit => 60 + t.boolean :electric + t.integer :volts, :default => 120 + + t.timestamps + end + end +end diff --git a/db/migrate/20120605030001_add_owner_to_tools.rb b/db/migrate/20120605030001_add_owner_to_tools.rb new file mode 100644 index 0000000..466d9b6 --- /dev/null +++ b/db/migrate/20120605030001_add_owner_to_tools.rb @@ -0,0 +1,10 @@ +class AddOwnerToTools < ActiveRecord::Migration + def down + remove_column :tools, :owner_id + end + def up + add_column :tools, :owner_id, :integer + Tool.update_all :owner_id => 1 + change_column :tools, :owner_id, :integer, :null => false + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..3c939fd --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,25 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20120605030001) do + + create_table "tools", :force => true do |t| + t.string "name", :limit => 60, :null => false + t.boolean "electric" + t.integer "volts", :default => 120 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_id", :null => false + end + +end diff --git a/test/fixtures/tools.yml b/test/fixtures/tools.yml new file mode 100644 index 0000000..c63aac0 --- /dev/null +++ b/test/fixtures/tools.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/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 diff --git a/test/functional/tools_controller_test.rb b/test/functional/tools_controller_test.rb new file mode 100644 index 0000000..5175c21 --- /dev/null +++ b/test/functional/tools_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class ToolsControllerTest < ActionController::TestCase + setup do + @tool = tools(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:tools) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create tool" do + assert_difference('Tool.count') do + post :create, tool: { } + end + + assert_redirected_to tool_path(assigns(:tool)) + end + + test "should show tool" do + get :show, id: @tool + assert_response :success + end + + test "should get edit" do + get :edit, id: @tool + assert_response :success + end + + test "should update tool" do + put :update, id: @tool, tool: { } + assert_redirected_to tool_path(assigns(:tool)) + end + + test "should destroy tool" do + assert_difference('Tool.count', -1) do + delete :destroy, id: @tool + end + + assert_redirected_to tools_path + end +end diff --git a/test/unit/helpers/tools_helper_test.rb b/test/unit/helpers/tools_helper_test.rb new file mode 100644 index 0000000..0677abe --- /dev/null +++ b/test/unit/helpers/tools_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ToolsHelperTest < ActionView::TestCase +end diff --git a/test/unit/tool_test.rb b/test/unit/tool_test.rb new file mode 100644 index 0000000..4d28156 --- /dev/null +++ b/test/unit/tool_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ToolTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 7c61de2ac0d5362dc85344e39fd7bd1ca3aa0116 Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 4 Jun 2012 23:20:15 -0500 Subject: [PATCH 03/19] Missing label in electric check_box --- app/views/tools/_form.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/tools/_form.html.erb b/app/views/tools/_form.html.erb index cbf2a19..512c4ad 100644 --- a/app/views/tools/_form.html.erb +++ b/app/views/tools/_form.html.erb @@ -14,6 +14,7 @@ <%= f.label :name %>: <%= f.text_field :name %>
+ <%= f.label :electric %>: <%= f.check_box :electric %>
<%= f.label :volts %>: From cdbb2f64bcc2e13fa8e8f891a92d04080fbd5d0e Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 4 Jun 2012 23:43:58 -0500 Subject: [PATCH 04/19] Make attributes accessible, remove null restriction on Tool.owner_id --- app/models/tool.rb | 2 +- app/views/tools/_form.html.erb | 1 - db/migrate/20120605030001_add_owner_to_tools.rb | 2 -- db/schema.rb | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/tool.rb b/app/models/tool.rb index 6046ad0..e2c62db 100644 --- a/app/models/tool.rb +++ b/app/models/tool.rb @@ -1,4 +1,4 @@ class Tool < ActiveRecord::Base # attr_accessible :title, :body - # testing + attr_accessible :name, :electric, :volts end diff --git a/app/views/tools/_form.html.erb b/app/views/tools/_form.html.erb index 512c4ad..747cecc 100644 --- a/app/views/tools/_form.html.erb +++ b/app/views/tools/_form.html.erb @@ -21,7 +21,6 @@ <%= f.text_field :volts %>
-
<%= f.submit %>
diff --git a/db/migrate/20120605030001_add_owner_to_tools.rb b/db/migrate/20120605030001_add_owner_to_tools.rb index 466d9b6..aea9f70 100644 --- a/db/migrate/20120605030001_add_owner_to_tools.rb +++ b/db/migrate/20120605030001_add_owner_to_tools.rb @@ -4,7 +4,5 @@ def down end def up add_column :tools, :owner_id, :integer - Tool.update_all :owner_id => 1 - change_column :tools, :owner_id, :integer, :null => false end end diff --git a/db/schema.rb b/db/schema.rb index 3c939fd..72b65a2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -19,7 +19,7 @@ t.integer "volts", :default => 120 t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.integer "owner_id", :null => false + t.integer "owner_id" end end From 6dbda5183f95b128ec7766707cbbfdd163c36440 Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 11 Jun 2012 19:11:43 -0500 Subject: [PATCH 05/19] http://localhost:3000/tools => Shows a list of tool names and options. --- app/views/tools/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/tools/index.html.erb b/app/views/tools/index.html.erb index d7f9b96..d7d836f 100644 --- a/app/views/tools/index.html.erb +++ b/app/views/tools/index.html.erb @@ -9,6 +9,7 @@ <% @tools.each do |tool| %> + <%= tool.name %> <%= link_to 'Show', tool %> <%= link_to 'Edit', edit_tool_path(tool) %> <%= link_to 'Destroy', tool, confirm: 'Are you sure?', method: :delete %> From 19f908c280f64331c7b8f25a711204bff6f3ac9a Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 11 Jun 2012 19:30:26 -0500 Subject: [PATCH 06/19] Show tools page can show tool info. --- app/views/tools/show.html.erb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/views/tools/show.html.erb b/app/views/tools/show.html.erb index d164fdd..501c40e 100644 --- a/app/views/tools/show.html.erb +++ b/app/views/tools/show.html.erb @@ -1,5 +1,19 @@

<%= notice %>

+

Show tool

+ + Name + <%= @tool.name%> +
+ Electric + <%= @tool.electric%> +
+ <% if @tool.electric %> + Voltage + <%= @tool.volts%> + <% end %> + +
<%= link_to 'Edit', edit_tool_path(@tool) %> | <%= link_to 'Back', tools_path %> From 19ba4f5ff65b1916aca3529a0264558c63690a1e Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 11 Jun 2012 21:36:24 -0500 Subject: [PATCH 07/19] Validates tool voltage if electric is true --- app/models/tool.rb | 6 +++++- app/views/tools/_form.html.erb | 1 - config/routes.rb | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/tool.rb b/app/models/tool.rb index e5daa95..53f0020 100644 --- a/app/models/tool.rb +++ b/app/models/tool.rb @@ -2,5 +2,9 @@ class Tool < ActiveRecord::Base # attr_accessible :title, :body attr_accessible :name, :electric, :volts validates :name, :presence => true - validates :volts, :if => :electric?, :greater_than => 0 + validates :volts, :numericality => {:greater_than => 0}, :if => :is_electrical? + + def is_electrical? + electric == true + end end diff --git a/app/views/tools/_form.html.erb b/app/views/tools/_form.html.erb index 747cecc..83ef715 100644 --- a/app/views/tools/_form.html.erb +++ b/app/views/tools/_form.html.erb @@ -20,7 +20,6 @@ <%= f.label :volts %>: <%= f.text_field :volts %>
-
<%= f.submit %>
diff --git a/config/routes.rb b/config/routes.rb index ff0ef76..e777f1e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ match "/dashboard" => "home#dashboard" + resources :tools resources :users, :only => [:show] match "/auth/:provider/callback" => "sessions#create" From c8f99758a245426c3bdbca8b57151dee7884ad5f Mon Sep 17 00:00:00 2001 From: beef Date: Tue, 26 Jun 2012 00:51:21 -0500 Subject: [PATCH 08/19] Skills, Skill_Holdings MVC, db migration. --- app/assets/javascripts/skill_holdings.js | 2 + app/assets/javascripts/skills.js | 2 + .../stylesheets/skill_holdings.css.scss | 3 + app/assets/stylesheets/skills.css.scss | 3 + app/controllers/skill_holdings_controller.rb | 42 +++++ app/controllers/skills_controller.rb | 83 +++++++++ app/helpers/skill_holdings_helper.rb | 2 + app/helpers/skills_helper.rb | 2 + app/models/skill.rb | 8 + app/models/skill_holding.rb | 24 +++ app/models/tool.rb | 5 +- app/models/user.rb | 3 + app/views/skill_holdings/_form.html.erb | 24 +++ app/views/skill_holdings/edit.html.erb | 5 + app/views/skill_holdings/index.html.erb | 22 +++ app/views/skill_holdings/new.html.erb | 5 + app/views/skills/_form.html.erb | 17 ++ app/views/skills/edit.html.erb | 6 + app/views/skills/index.html.erb | 21 +++ app/views/skills/new.html.erb | 5 + app/views/skills/show.html.erb | 5 + config/routes.rb | 6 +- db/migrate/20120626022507_create_skills.rb | 18 ++ db/schema.rb | 26 ++- .../skill_holdings_controller_spec.rb | 5 + spec/controllers/skills_controller_spec.rb | 164 ++++++++++++++++++ spec/helpers/skill_holdings_helper_spec.rb | 15 ++ spec/helpers/skills_helper_spec.rb | 15 ++ spec/models/skill_spec.rb | 5 + spec/requests/skills_spec.rb | 11 ++ spec/routing/skills_routing_spec.rb | 35 ++++ spec/views/skills/edit.html.erb_spec.rb | 15 ++ spec/views/skills/index.html.erb_spec.rb | 15 ++ spec/views/skills/new.html.erb_spec.rb | 15 ++ spec/views/skills/show.html.erb_spec.rb | 12 ++ 35 files changed, 640 insertions(+), 6 deletions(-) create mode 100644 app/assets/javascripts/skill_holdings.js create mode 100644 app/assets/javascripts/skills.js create mode 100644 app/assets/stylesheets/skill_holdings.css.scss create mode 100644 app/assets/stylesheets/skills.css.scss create mode 100644 app/controllers/skill_holdings_controller.rb create mode 100644 app/controllers/skills_controller.rb create mode 100644 app/helpers/skill_holdings_helper.rb create mode 100644 app/helpers/skills_helper.rb create mode 100644 app/models/skill.rb create mode 100644 app/models/skill_holding.rb create mode 100644 app/views/skill_holdings/_form.html.erb create mode 100644 app/views/skill_holdings/edit.html.erb create mode 100644 app/views/skill_holdings/index.html.erb create mode 100644 app/views/skill_holdings/new.html.erb create mode 100644 app/views/skills/_form.html.erb create mode 100644 app/views/skills/edit.html.erb create mode 100644 app/views/skills/index.html.erb create mode 100644 app/views/skills/new.html.erb create mode 100644 app/views/skills/show.html.erb create mode 100644 db/migrate/20120626022507_create_skills.rb create mode 100644 spec/controllers/skill_holdings_controller_spec.rb create mode 100644 spec/controllers/skills_controller_spec.rb create mode 100644 spec/helpers/skill_holdings_helper_spec.rb create mode 100644 spec/helpers/skills_helper_spec.rb create mode 100644 spec/models/skill_spec.rb create mode 100644 spec/requests/skills_spec.rb create mode 100644 spec/routing/skills_routing_spec.rb create mode 100644 spec/views/skills/edit.html.erb_spec.rb create mode 100644 spec/views/skills/index.html.erb_spec.rb create mode 100644 spec/views/skills/new.html.erb_spec.rb create mode 100644 spec/views/skills/show.html.erb_spec.rb diff --git a/app/assets/javascripts/skill_holdings.js b/app/assets/javascripts/skill_holdings.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/skill_holdings.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/skills.js b/app/assets/javascripts/skills.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/skills.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/skill_holdings.css.scss b/app/assets/stylesheets/skill_holdings.css.scss new file mode 100644 index 0000000..b6a3c44 --- /dev/null +++ b/app/assets/stylesheets/skill_holdings.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the skill_holdings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/skills.css.scss b/app/assets/stylesheets/skills.css.scss new file mode 100644 index 0000000..b6c781d --- /dev/null +++ b/app/assets/stylesheets/skills.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the skills controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/skill_holdings_controller.rb b/app/controllers/skill_holdings_controller.rb new file mode 100644 index 0000000..6a93b24 --- /dev/null +++ b/app/controllers/skill_holdings_controller.rb @@ -0,0 +1,42 @@ +class SkillHoldingsController < ApplicationController + + def create + @skill_holding = current_user.skill_holdings.build(params[:skill_holding]) + + if @skill_holding.save + redirect_to user_skill_holdings_url(current_user.id) + else + # render :action => "new" + render action: "new" + end + end + + def destroy + @skill_holding = current_user.skill_holdings.find(params[:id]) + @skill_holding.destroy + redirect_to user_skill_holdings_url(current_user.id) + end + + def edit + @skill_holding = current_user.skill_holdings.find(params[:id]) + end + + def index + @skill_holdings = current_user.skill_holdings + end + + def new + @skill_holding = current_user.skill_holdings.build + end + + def update + @skill_holding = current_user.skill_holdings.find(params[:id]) + + if @skill_holding.update_attributes(params[:skill_holding]) + redirect_to user_skill_holdings_url(current_user.id) + else + render action: "edit" + end + end + +end diff --git a/app/controllers/skills_controller.rb b/app/controllers/skills_controller.rb new file mode 100644 index 0000000..e18ca4e --- /dev/null +++ b/app/controllers/skills_controller.rb @@ -0,0 +1,83 @@ +class SkillsController < ApplicationController + # GET /skills + # GET /skills.json + def index + @skills = Skill.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @skills } + end + end + + # GET /skills/1 + # GET /skills/1.json + def show + @skill = Skill.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @skill } + end + end + + # GET /skills/new + # GET /skills/new.json + def new + @skill = Skill.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @skill } + end + end + + # GET /skills/1/edit + def edit + @skill = Skill.find(params[:id]) + end + + # POST /skills + # POST /skills.json + def create + @skill = Skill.new(params[:skill]) + + respond_to do |format| + if @skill.save + format.html { redirect_to @skill, notice: 'Skill was successfully created.' } + format.json { render json: @skill, status: :created, location: @skill } + else + format.html { render action: "new" } + format.json { render json: @skill.errors, status: :unprocessable_entity } + end + end + end + + # PUT /skills/1 + # PUT /skills/1.json + def update + @skill = Skill.find(params[:id]) + + respond_to do |format| + if @skill.update_attributes(params[:skill]) + format.html { redirect_to @skill, notice: 'Skill was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @skill.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /skills/1 + # DELETE /skills/1.json + def destroy + @skill = Skill.find(params[:id]) + @skill.destroy + + respond_to do |format| + format.html { redirect_to skills_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/skill_holdings_helper.rb b/app/helpers/skill_holdings_helper.rb new file mode 100644 index 0000000..e1e8757 --- /dev/null +++ b/app/helpers/skill_holdings_helper.rb @@ -0,0 +1,2 @@ +module SkillHoldingsHelper +end diff --git a/app/helpers/skills_helper.rb b/app/helpers/skills_helper.rb new file mode 100644 index 0000000..5a66444 --- /dev/null +++ b/app/helpers/skills_helper.rb @@ -0,0 +1,2 @@ +module SkillsHelper +end diff --git a/app/models/skill.rb b/app/models/skill.rb new file mode 100644 index 0000000..30cb08a --- /dev/null +++ b/app/models/skill.rb @@ -0,0 +1,8 @@ +class Skill < ActiveRecord::Base + + has_many :skill_holdings + has_many :users, :through => :skill_holdings + + validates :name, :presence => true, :length => {:maximum => 60}, :uniqueness => true + +end diff --git a/app/models/skill_holding.rb b/app/models/skill_holding.rb new file mode 100644 index 0000000..651ec7e --- /dev/null +++ b/app/models/skill_holding.rb @@ -0,0 +1,24 @@ +class SkillHolding < ActiveRecord::Base + + attr_accessible :level, :name + + belongs_to :user + belongs_to :skill + + validates :level, :numericality => {:minimum => 0, :maximum => 4} + validates :user_id, :presence => true + validates :skill_id, :presence => true + + SKILL_LEVELS = ["Interested in", "Novice", "Intermediate", "Experienced" , "Guru"] + + def name + skill && skill.name + end + + def name=(skill_name) + self.skill = Skill.find_or_create_by_name(skill_name) + save + return name + end + +end diff --git a/app/models/tool.rb b/app/models/tool.rb index 53f0020..b36babc 100644 --- a/app/models/tool.rb +++ b/app/models/tool.rb @@ -2,9 +2,6 @@ class Tool < ActiveRecord::Base # attr_accessible :title, :body attr_accessible :name, :electric, :volts validates :name, :presence => true - validates :volts, :numericality => {:greater_than => 0}, :if => :is_electrical? + validates :volts, :numericality => {:greater_than => 0}, :if => Proc.new{|tool| tool.electric?} - def is_electrical? - electric == true - end end diff --git a/app/models/user.rb b/app/models/user.rb index 18df122..e1324fd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,6 +10,9 @@ class User < ActiveRecord::Base }, :options => { :skip_provider_check => true } + has_many :skill_holdings + has_many :skills, :through => :skill_holdings + has_one :facebook_profile, :dependent => :destroy, :inverse_of => :user validates :first_name, :presence => true diff --git a/app/views/skill_holdings/_form.html.erb b/app/views/skill_holdings/_form.html.erb new file mode 100644 index 0000000..ac7cbb5 --- /dev/null +++ b/app/views/skill_holdings/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for([current_user, @skill_holding]) do |sh| %> + <% if @skill_holding.errors.any? %> +
+

<%= pluralize(@skill_holding.errors.count, "error") %> prohibited this skill holidng from being saved:

+ +
    + <% @skill_holding.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + + <%= sh.label :name %>: + <%# @skill_holding.inspect %> + <%= sh.text_field :name %>
+ + <%= sh.label :level %>: + <%= sh.select :level, SkillHolding::SKILL_LEVELS.collect {|level| [level, SkillHolding::SKILL_LEVELS.find_index(level)] } %>
+ +
+ <%= sh.submit %> +
+<% end %> diff --git a/app/views/skill_holdings/edit.html.erb b/app/views/skill_holdings/edit.html.erb new file mode 100644 index 0000000..ff2c7b9 --- /dev/null +++ b/app/views/skill_holdings/edit.html.erb @@ -0,0 +1,5 @@ +

Editing skill

+ +<%= render 'form' %> + +<%= link_to 'Back', user_skill_holdings_path(current_user) %> diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb new file mode 100644 index 0000000..75f6bee --- /dev/null +++ b/app/views/skill_holdings/index.html.erb @@ -0,0 +1,22 @@ +

Listing my skills

+ + + + + + + + +<% @skill_holdings.each do |skill_holding| %> + + + + + + +<% end %> +
NameLevel
<%= skill_holding.name %><%= skill_holding.level %><%= link_to 'Edit', edit_user_skill_holding_path(current_user.id, skill_holding.id) %><%= link_to 'Destroy', user_skill_holding_path(current_user.id, skill_holding.id), confirm: 'Are you sure?', method: :delete %>
+ +
+ +<%= link_to 'New Skill', new_user_skill_holding_path(current_user.id) %> diff --git a/app/views/skill_holdings/new.html.erb b/app/views/skill_holdings/new.html.erb new file mode 100644 index 0000000..c730498 --- /dev/null +++ b/app/views/skill_holdings/new.html.erb @@ -0,0 +1,5 @@ +

New skill

+ +<%= render 'form' %> + +<%= link_to 'Back', user_skill_holdings_path(current_user) %> diff --git a/app/views/skills/_form.html.erb b/app/views/skills/_form.html.erb new file mode 100644 index 0000000..3b231ec --- /dev/null +++ b/app/views/skills/_form.html.erb @@ -0,0 +1,17 @@ +<%= form_for(@skill) do |f| %> + <% if @skill.errors.any? %> +
+

<%= pluralize(@skill.errors.count, "error") %> prohibited this skill from being saved:

+ +
    + <% @skill.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/skills/edit.html.erb b/app/views/skills/edit.html.erb new file mode 100644 index 0000000..60a41d1 --- /dev/null +++ b/app/views/skills/edit.html.erb @@ -0,0 +1,6 @@ +

Editing skill

+ +<%= render 'form' %> + +<%= link_to 'Show', @skill %> | +<%= link_to 'Back', skills_path %> diff --git a/app/views/skills/index.html.erb b/app/views/skills/index.html.erb new file mode 100644 index 0000000..88d29ca --- /dev/null +++ b/app/views/skills/index.html.erb @@ -0,0 +1,21 @@ +

Listing skills

+ + + + + + + + +<% @skills.each do |skill| %> + + + + + +<% end %> +
<%= link_to 'Show', skill %><%= link_to 'Edit', edit_skill_path(skill) %><%= link_to 'Destroy', skill, confirm: 'Are you sure?', method: :delete %>
+ +
+ +<%= link_to 'New Skill', new_skill_path %> diff --git a/app/views/skills/new.html.erb b/app/views/skills/new.html.erb new file mode 100644 index 0000000..a67d54b --- /dev/null +++ b/app/views/skills/new.html.erb @@ -0,0 +1,5 @@ +

New skill

+ +<%= render 'form' %> + +<%= link_to 'Back', skills_path %> diff --git a/app/views/skills/show.html.erb b/app/views/skills/show.html.erb new file mode 100644 index 0000000..9756e29 --- /dev/null +++ b/app/views/skills/show.html.erb @@ -0,0 +1,5 @@ +

<%= notice %>

+ + +<%= link_to 'Edit', edit_skill_path(@skill) %> | +<%= link_to 'Back', skills_path %> diff --git a/config/routes.rb b/config/routes.rb index e777f1e..27563c6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,13 @@ WhosGotWhat::Application.routes.draw do + resources :skills + match "/dashboard" => "home#dashboard" resources :tools - resources :users, :only => [:show] + resources :users, :only => [:show] do + resources :skill_holdings, :except => [:show] + end match "/auth/:provider/callback" => "sessions#create" match "/auth/failure", to: "sessions#failure" diff --git a/db/migrate/20120626022507_create_skills.rb b/db/migrate/20120626022507_create_skills.rb new file mode 100644 index 0000000..fc5d332 --- /dev/null +++ b/db/migrate/20120626022507_create_skills.rb @@ -0,0 +1,18 @@ +class CreateSkills < ActiveRecord::Migration + def change + create_table :skills do |s| + s.string :name, :null => false, :limit => 60 + end + + create_table :skill_holdings do |sh| + sh.integer :user_id, :null => false + sh.integer :skill_id, :null => false + sh.integer :level, :null => false + end + + add_index :skills, :name, :unique => true + add_index :skill_holdings, :user_id + add_index :skill_holdings, :skill_id + + end +end diff --git a/db/schema.rb b/db/schema.rb index 1883d78..3f037fa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120605043307) do +ActiveRecord::Schema.define(:version => 20120626022507) do create_table "facebook_profiles", :force => true do |t| t.string "email", :null => false @@ -59,6 +59,30 @@ add_index "roles_users", ["user_id", "role_id"], :name => "index_roles_users_on_user_id_and_role_id", :unique => true + create_table "skill_holdings", :force => true do |t| + t.integer "user_id", :null => false + t.integer "skill_id", :null => false + t.integer "level", :null => false + end + + add_index "skill_holdings", ["skill_id"], :name => "index_skill_holdings_on_skill_id" + add_index "skill_holdings", ["user_id"], :name => "index_skill_holdings_on_user_id" + + create_table "skills", :force => true do |t| + t.string "name", :limit => 60, :null => false + end + + add_index "skills", ["name"], :name => "index_skills_on_name", :unique => true + + create_table "tools", :force => true do |t| + t.string "name", :limit => 60, :null => false + t.boolean "electric" + t.integer "volts", :default => 120 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_id" + end + create_table "users", :force => true do |t| t.string "first_name", :limit => 60, :null => false t.string "last_name", :limit => 60, :null => false diff --git a/spec/controllers/skill_holdings_controller_spec.rb b/spec/controllers/skill_holdings_controller_spec.rb new file mode 100644 index 0000000..22b4bb9 --- /dev/null +++ b/spec/controllers/skill_holdings_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe SkillHoldingsController do + +end diff --git a/spec/controllers/skills_controller_spec.rb b/spec/controllers/skills_controller_spec.rb new file mode 100644 index 0000000..2220fdf --- /dev/null +++ b/spec/controllers/skills_controller_spec.rb @@ -0,0 +1,164 @@ +require 'spec_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +describe SkillsController do + + # This should return the minimal set of attributes required to create a valid + # Skill. As you add validations to Skill, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # SkillsController. Be sure to keep this updated too. + def valid_session + {} + end + + describe "GET index" do + it "assigns all skills as @skills" do + skill = Skill.create! valid_attributes + get :index, {}, valid_session + assigns(:skills).should eq([skill]) + end + end + + describe "GET show" do + it "assigns the requested skill as @skill" do + skill = Skill.create! valid_attributes + get :show, {:id => skill.to_param}, valid_session + assigns(:skill).should eq(skill) + end + end + + describe "GET new" do + it "assigns a new skill as @skill" do + get :new, {}, valid_session + assigns(:skill).should be_a_new(Skill) + end + end + + describe "GET edit" do + it "assigns the requested skill as @skill" do + skill = Skill.create! valid_attributes + get :edit, {:id => skill.to_param}, valid_session + assigns(:skill).should eq(skill) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Skill" do + expect { + post :create, {:skill => valid_attributes}, valid_session + }.to change(Skill, :count).by(1) + end + + it "assigns a newly created skill as @skill" do + post :create, {:skill => valid_attributes}, valid_session + assigns(:skill).should be_a(Skill) + assigns(:skill).should be_persisted + end + + it "redirects to the created skill" do + post :create, {:skill => valid_attributes}, valid_session + response.should redirect_to(Skill.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved skill as @skill" do + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + post :create, {:skill => {}}, valid_session + assigns(:skill).should be_a_new(Skill) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + post :create, {:skill => {}}, valid_session + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested skill" do + skill = Skill.create! valid_attributes + # Assuming there are no other skills in the database, this + # specifies that the Skill created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Skill.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, {:id => skill.to_param, :skill => {'these' => 'params'}}, valid_session + end + + it "assigns the requested skill as @skill" do + skill = Skill.create! valid_attributes + put :update, {:id => skill.to_param, :skill => valid_attributes}, valid_session + assigns(:skill).should eq(skill) + end + + it "redirects to the skill" do + skill = Skill.create! valid_attributes + put :update, {:id => skill.to_param, :skill => valid_attributes}, valid_session + response.should redirect_to(skill) + end + end + + describe "with invalid params" do + it "assigns the skill as @skill" do + skill = Skill.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + put :update, {:id => skill.to_param, :skill => {}}, valid_session + assigns(:skill).should eq(skill) + end + + it "re-renders the 'edit' template" do + skill = Skill.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + put :update, {:id => skill.to_param, :skill => {}}, valid_session + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested skill" do + skill = Skill.create! valid_attributes + expect { + delete :destroy, {:id => skill.to_param}, valid_session + }.to change(Skill, :count).by(-1) + end + + it "redirects to the skills list" do + skill = Skill.create! valid_attributes + delete :destroy, {:id => skill.to_param}, valid_session + response.should redirect_to(skills_url) + end + end + +end diff --git a/spec/helpers/skill_holdings_helper_spec.rb b/spec/helpers/skill_holdings_helper_spec.rb new file mode 100644 index 0000000..d7c1cd7 --- /dev/null +++ b/spec/helpers/skill_holdings_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the SkillHoldingsHelper. For example: +# +# describe SkillHoldingsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe SkillHoldingsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/skills_helper_spec.rb b/spec/helpers/skills_helper_spec.rb new file mode 100644 index 0000000..f353bf0 --- /dev/null +++ b/spec/helpers/skills_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the SkillsHelper. For example: +# +# describe SkillsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe SkillsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/skill_spec.rb b/spec/models/skill_spec.rb new file mode 100644 index 0000000..1b1c077 --- /dev/null +++ b/spec/models/skill_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Skill do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/skills_spec.rb b/spec/requests/skills_spec.rb new file mode 100644 index 0000000..c1f8f14 --- /dev/null +++ b/spec/requests/skills_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe "Skills" do + describe "GET /skills" do + it "works! (now write some real specs)" do + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + get skills_path + response.status.should be(200) + end + end +end diff --git a/spec/routing/skills_routing_spec.rb b/spec/routing/skills_routing_spec.rb new file mode 100644 index 0000000..d2e6e2e --- /dev/null +++ b/spec/routing/skills_routing_spec.rb @@ -0,0 +1,35 @@ +require "spec_helper" + +describe SkillsController do + describe "routing" do + + it "routes to #index" do + get("/skills").should route_to("skills#index") + end + + it "routes to #new" do + get("/skills/new").should route_to("skills#new") + end + + it "routes to #show" do + get("/skills/1").should route_to("skills#show", :id => "1") + end + + it "routes to #edit" do + get("/skills/1/edit").should route_to("skills#edit", :id => "1") + end + + it "routes to #create" do + post("/skills").should route_to("skills#create") + end + + it "routes to #update" do + put("/skills/1").should route_to("skills#update", :id => "1") + end + + it "routes to #destroy" do + delete("/skills/1").should route_to("skills#destroy", :id => "1") + end + + end +end diff --git a/spec/views/skills/edit.html.erb_spec.rb b/spec/views/skills/edit.html.erb_spec.rb new file mode 100644 index 0000000..b1330b3 --- /dev/null +++ b/spec/views/skills/edit.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "skills/edit" do + before(:each) do + @skill = assign(:skill, stub_model(Skill)) + end + + it "renders the edit skill form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => skills_path(@skill), :method => "post" do + end + end +end diff --git a/spec/views/skills/index.html.erb_spec.rb b/spec/views/skills/index.html.erb_spec.rb new file mode 100644 index 0000000..cae82bc --- /dev/null +++ b/spec/views/skills/index.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "skills/index" do + before(:each) do + assign(:skills, [ + stub_model(Skill), + stub_model(Skill) + ]) + end + + it "renders a list of skills" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end diff --git a/spec/views/skills/new.html.erb_spec.rb b/spec/views/skills/new.html.erb_spec.rb new file mode 100644 index 0000000..1f3ace4 --- /dev/null +++ b/spec/views/skills/new.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "skills/new" do + before(:each) do + assign(:skill, stub_model(Skill).as_new_record) + end + + it "renders new skill form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => skills_path, :method => "post" do + end + end +end diff --git a/spec/views/skills/show.html.erb_spec.rb b/spec/views/skills/show.html.erb_spec.rb new file mode 100644 index 0000000..e8c1e28 --- /dev/null +++ b/spec/views/skills/show.html.erb_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "skills/show" do + before(:each) do + @skill = assign(:skill, stub_model(Skill)) + end + + it "renders attributes in

" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end From 3b9d708191da4e8cf21daa007e2a16a7e304d7ca Mon Sep 17 00:00:00 2001 From: beef Date: Tue, 26 Jun 2012 01:09:52 -0500 Subject: [PATCH 09/19] Fixed string display of skill level in index. --- app/views/skill_holdings/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb index 75f6bee..70558a0 100644 --- a/app/views/skill_holdings/index.html.erb +++ b/app/views/skill_holdings/index.html.erb @@ -10,7 +10,7 @@ <% @skill_holdings.each do |skill_holding| %> <%= skill_holding.name %> - <%= skill_holding.level %> + <%= SkillHolding::SKILL_LEVELS[skill_holding.level] %> <%= link_to 'Edit', edit_user_skill_holding_path(current_user.id, skill_holding.id) %> <%= link_to 'Destroy', user_skill_holding_path(current_user.id, skill_holding.id), confirm: 'Are you sure?', method: :delete %> From e913b319aed1d79ea58d04efc5b0fdf68dd54452 Mon Sep 17 00:00:00 2001 From: beef Date: Wed, 27 Jun 2012 06:36:38 -0500 Subject: [PATCH 10/19] Added link to Skills owned by current_user and Tools index on the dashboard page. Display current path (for debuging) and link to dashboard on all pages at the bottom. Must figure out footers. New method to show Skill level as a string. --- app/models/skill_holding.rb | 4 ++++ app/views/home/dashboard.html.erb | 6 +++++- app/views/layouts/application.html.erb | 5 +++++ app/views/skill_holdings/index.html.erb | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/models/skill_holding.rb b/app/models/skill_holding.rb index 651ec7e..42e1e4b 100644 --- a/app/models/skill_holding.rb +++ b/app/models/skill_holding.rb @@ -11,6 +11,10 @@ class SkillHolding < ActiveRecord::Base SKILL_LEVELS = ["Interested in", "Novice", "Intermediate", "Experienced" , "Guru"] + def level_name + level && SKILL_LEVELS[level] + end + def name skill && skill.name end diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index f87cae5..434f264 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -1 +1,5 @@ -Welcome <%= current_user.name %> +Welcome <%= current_user.name %>
+
+<%= link_to "My skills", user_skill_holdings_path(current_user) %>
+<%= link_to "All Tools", tools_path %>
+ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 27f07d7..29c2b30 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,5 +12,10 @@ <%= content_for?(:content) ? yield(:content) : yield %> +



+ +<%= link_to "Dashboard", dashboard_path %>
+Current Path <%= request.env['PATH_INFO'] %> + diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb index 70558a0..d331d52 100644 --- a/app/views/skill_holdings/index.html.erb +++ b/app/views/skill_holdings/index.html.erb @@ -10,7 +10,7 @@ <% @skill_holdings.each do |skill_holding| %> <%= skill_holding.name %> - <%= SkillHolding::SKILL_LEVELS[skill_holding.level] %> + <%= skill_holding.level_name %> <%= link_to 'Edit', edit_user_skill_holding_path(current_user.id, skill_holding.id) %> <%= link_to 'Destroy', user_skill_holding_path(current_user.id, skill_holding.id), confirm: 'Are you sure?', method: :delete %> From 6783fc76aaf9bc551d4082525aa4df6e2464f159 Mon Sep 17 00:00:00 2001 From: beef Date: Sun, 15 Jul 2012 12:10:42 -0500 Subject: [PATCH 11/19] CSS formatting for Skills entry and display. --- app/views/home/dashboard.html.erb | 1 + app/views/skill_holdings/_form.html.erb | 53 ++++++++++++++++++++----- app/views/skill_holdings/index.html.erb | 42 +++++++++++++++++--- app/views/skill_holdings/new.html.erb | 2 +- 4 files changed, 83 insertions(+), 15 deletions(-) diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 434f264..bd9161a 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -1,5 +1,6 @@ Welcome <%= current_user.name %>

<%= link_to "My skills", user_skill_holdings_path(current_user) %>
+
<%= link_to "All Tools", tools_path %>
diff --git a/app/views/skill_holdings/_form.html.erb b/app/views/skill_holdings/_form.html.erb index ac7cbb5..c9fc293 100644 --- a/app/views/skill_holdings/_form.html.erb +++ b/app/views/skill_holdings/_form.html.erb @@ -1,3 +1,23 @@ + <%= form_for([current_user, @skill_holding]) do |sh| %> <% if @skill_holding.errors.any? %>

@@ -11,14 +31,29 @@
<% end %> - <%= sh.label :name %>: - <%# @skill_holding.inspect %> - <%= sh.text_field :name %>
+ + + + + + + + + + + + + +
+ <%= sh.label :name, :class => "label_text" %> + + <%= sh.text_field :name %> +
+ <%= sh.label :level, :class => 'label_text' %> + + <%= sh.select :level, SkillHolding::SKILL_LEVELS.collect {|level| [level, SkillHolding::SKILL_LEVELS.find_index(level)] } %> +
+ <%= sh.submit "Add New Skill" %> +
- <%= sh.label :level %>: - <%= sh.select :level, SkillHolding::SKILL_LEVELS.collect {|level| [level, SkillHolding::SKILL_LEVELS.find_index(level)] } %>
- -
- <%= sh.submit %> -
<% end %> diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb index d331d52..132b6ad 100644 --- a/app/views/skill_holdings/index.html.erb +++ b/app/views/skill_holdings/index.html.erb @@ -1,18 +1,50 @@ -

Listing my skills

+ + +

Listing My skills

- + <% @skill_holdings.each do |skill_holding| %> - - - + + <% end %>
Name LevelActions
<%= skill_holding.name %><%= skill_holding.level_name %> <%= link_to 'Edit', edit_user_skill_holding_path(current_user.id, skill_holding.id) %><%= link_to 'Destroy', user_skill_holding_path(current_user.id, skill_holding.id), confirm: 'Are you sure?', method: :delete %><%= skill_holding.level_name %><%= link_to 'Edit', edit_user_skill_holding_path(current_user.id, skill_holding.id) %>, + <%= link_to 'Remove', user_skill_holding_path(current_user.id, skill_holding.id), confirm: 'Are you sure?', method: :delete %>
diff --git a/app/views/skill_holdings/new.html.erb b/app/views/skill_holdings/new.html.erb index c730498..61c839f 100644 --- a/app/views/skill_holdings/new.html.erb +++ b/app/views/skill_holdings/new.html.erb @@ -1,4 +1,4 @@ -

New skill

+

New Skill

<%= render 'form' %> From 43f3ab669086a9a9b15771c0577297462b7962bb Mon Sep 17 00:00:00 2001 From: beef Date: Sun, 15 Jul 2012 18:27:52 -0500 Subject: [PATCH 12/19] My attempt at CSS sticky footers. --- app/views/layouts/application.html.erb | 43 +++++++++++++++++++------ app/views/skill_holdings/_form.html.erb | 2 +- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 29c2b30..dd3ecdb 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,4 +1,26 @@ +> WhosGotWhat @@ -7,15 +29,16 @@ <%= csrf_meta_tags %> - -<%= render 'shared/flashes' %> - -<%= content_for?(:content) ? yield(:content) : yield %> - -



- -<%= link_to "Dashboard", dashboard_path %>
-Current Path <%= request.env['PATH_INFO'] %> - +
+
+ <%= render 'shared/flashes' %> + <%= content_for?(:content) ? yield(:content) : yield %> +
+
+ diff --git a/app/views/skill_holdings/_form.html.erb b/app/views/skill_holdings/_form.html.erb index c9fc293..bbbbf0c 100644 --- a/app/views/skill_holdings/_form.html.erb +++ b/app/views/skill_holdings/_form.html.erb @@ -3,7 +3,7 @@ font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-size: 12px; background: #CCCCCC; - margin: 5px; + margin: 40px; width: 200px; border-collapse: collapse; // text-align: left; From d445ead30d3026f6cf4ec52082dcea36f8b6b859 Mon Sep 17 00:00:00 2001 From: beef Date: Sat, 21 Jul 2012 23:28:55 -0500 Subject: [PATCH 13/19] Initial app logo and playing with javascript. --- app/views/layouts/application.html.erb | 45 +++++++++++++++++++------ public/WhosGotWhat_728x90.png | Bin 0 -> 2052 bytes public/WhosGotWhat_728x90.xcf | Bin 0 -> 7227 bytes 3 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 public/WhosGotWhat_728x90.png create mode 100644 public/WhosGotWhat_728x90.xcf diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index dd3ecdb..bd0de8f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,4 +1,6 @@ + + > - + + + + WhosGotWhat <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> + -
+
+
+ Who's Got What' +
+
<%= render 'shared/flashes' %> <%= content_for?(:content) ? yield(:content) : yield %>
-
- + + + Current Path: <%= request.env['PATH_INFO'] %> +
+ +
+ + + diff --git a/public/WhosGotWhat_728x90.png b/public/WhosGotWhat_728x90.png new file mode 100644 index 0000000000000000000000000000000000000000..06325308543c50ef0cae454cc95d016f82326cb8 GIT binary patch literal 2052 zcmV+f2>bVmP)WFU8GbZ8()Nlj27Z*CxAAWdOohp2Z$000MLNkl3IME00000000000000000000 z0DxbHB>?zeA^!rfBEiR|*Qs9ke!7lv;hdPa&-STyQ*G~2U)5I{_^<>3$C~QTUR$vS zNbc33Xer*nS7I|R8;g9=`y8k%)`7%v?hZDfDBnFkceI@YAX%J$=MMI0v{*MLTSXRn zHdXFs*I!%p)%sH`&R^CYkZfHLxWEF$`8*yG0VLa8<9D}BV+~v$=dVtamDE8Dnn&yX z4` z!`*d&;!eEDv0HIbOd+?i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yGT#v2=jJ-%HVa6LcKIEFo%^j@f<;FchiE%H(5U#$VT~TL2xusjt0=8WdxB$r=sk+ zS4kbx$3W%ZXFxqRE>MQ7a?O-ZV%Nu&IWy`Ks-C8Yad|^ZsQhmoB~*U8YWZUs{nsaq zGL}k*CbQI;v51D&FbbIPC14Wysi^J4x7uNKo2 literal 0 HcmV?d00001 From 6627ed4cda971d141ddbf22fc3108343a585fbfe Mon Sep 17 00:00:00 2001 From: beef Date: Sun, 22 Jul 2012 10:22:54 -0500 Subject: [PATCH 14/19] Initial logo does not show up in Google Chrome due to some script which adds a disabling style upon render. Firefox and Safari render properly. Initial favicon.ico and Gimp XCF --- app/views/layouts/application.html.erb | 4 ++-- public/favicon.ico | Bin 0 -> 1566 bytes public/favicon.xcf | Bin 0 -> 3887 bytes 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 public/favicon.xcf diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bd0de8f..bc40e82 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -39,7 +39,7 @@
- Who's Got What' + Whos Got What

<%= render 'shared/flashes' %> @@ -58,7 +58,7 @@ document.write("User-agent header sent: " + navigator.userAgent + "
"); document.write("Screen (" + screen.width + "," + screen.height + "), "); document.write("Available (" + screen.availWidth + "," + screen.availHeight + "), "); - document.write("Inner (" + window.top.innerWidth + "," + window.innerHeight + ")"); + document.write("Inner (" + window.innerWidth + "," + window.innerHeight + ")"); //]]>
diff --git a/public/favicon.ico b/public/favicon.ico index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ca350aa750a4876d1588f027a9f4b9f5f285e53e 100644 GIT binary patch literal 1566 zcmZQzU}Rur5D*Xm(ku)bj0_B63=AmzI-nS`{4yp~{yAn;{x=o|1`UuIK&$}7Aan77 z|1J1riIHOzgs7r5jp>&EKNuKRaWF8fegVNC_9~!Q6OabUweMhH*ewCX5kNK&?*gg= u;Wi)!$!h?O9J=9z86LReVPu38@!>Ht!inT7eQ()zoHB6G( z+Zc~)n4HYlF{>Nz7^8`?ig^k1GUiP!Q``;2KgHT`k*IA4gMs5m(38E_9)^w;IbHS2 zi+0rJldWee@Rg;uESo}B5{x&nT&L}ZUe~~8%~5pFcho58d)-#8*>mlnAB3uzEbY+U zwp8bKCm9Qbb?s^ay1f8u{OV+Zp!=htWqZDxggrnq*bWxhw5h%4dyyIjo*#_}9rSu5 zC(4dT;Ga#YC53vvz2g8%zk(k8D}MCXj4ibpTmHsa{f+TpH5XZdy!JS>29CO~n(H{| zVAN90&>8kE+i4MkE{!gaZn&ytENnR^-^$5!28yR~1=Gm&oZQICS0U5BW-LK4m^^W` zU%c0Xc?IxKd@S0;XVU9Zu$cruxtuY{<&;SfYbr@ThJ2!lbDrRYoKTpAo}$K3iWclc zn{p{qh)h!nj^t#KbOL%{k8y%c@NgbxTIxO0x}=^QCrUWP0gu>>iF)0NL_8~VnsqiwiuZVSWNhe4iJRT=l!sBO;4~?e1M_QNq zoMpWnPYH01=ALs@y?2hOO2^cr@<^P;Wdk*?X2r)oyJIaL>!a1#Zp(v5>i zTxL|wEEiP$8&th}j;U&@EC{&ty+}*?s#lF))3-|1`0P{#dka*}*ql){v&^ZQvfETu zQ_?T0Dr)R+uc~*>F;%6eCzjd=E$6Cg?NiZK`$GDetLmAk`ilktb-2&~u)+r&-tq^( ztQX>O!vC@XSlzJfT{jH&{BFipx@wfGWGre{>7T}*Y*x)#khZaz9xH2N;A^}n+8Vp0 z*9H1TLCva|F~P+Y544@IaB&RtX{H1x#Dv1;s4qA9`_1YPqFGC` literal 0 HcmV?d00001 From c2148c3183f9e647ad96e5bf76bbfddf382a18a7 Mon Sep 17 00:00:00 2001 From: beef Date: Sun, 22 Jul 2012 10:38:07 -0500 Subject: [PATCH 15/19] favicon edits --- public/favicon.ico | Bin 1566 -> 458 bytes public/favicon.xcf | Bin 3887 -> 4664 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/favicon.ico b/public/favicon.ico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@XSlzJfT{jH&{BFipx@wfGWGre{>7T}*Y*x)#khZaz9xH2N;A^}n+8Vp0 z*9H1TLCva|F~P+Y544@IaB&RtX{H1x#Dv1;s4qA9`_1YPqFGC` From 7143dd9a7a3fdc190e794c31c6ae70fba4d53d12 Mon Sep 17 00:00:00 2001 From: beef Date: Sun, 22 Jul 2012 14:09:41 -0500 Subject: [PATCH 16/19] Format dashboard, add template to link all Skills and User Tools, clean New Skill link. --- app/views/home/dashboard.html.erb | 62 +++++++++++++++++++++++-- app/views/skill_holdings/index.html.erb | 11 ++++- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index bd9161a..07e4dce 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -1,6 +1,58 @@ -Welcome <%= current_user.name %>
-
-<%= link_to "My skills", user_skill_holdings_path(current_user) %>
-
-<%= link_to "All Tools", tools_path %>
+ + +

Welcome <%= current_user.name %>

+ + + + + + + + + + +
+ <%= link_to "My skills", user_skill_holdings_path(current_user) %> + + All Skills +
+ My Tools + + <%= link_to "All Tools", tools_path %> +
+ diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb index 132b6ad..5485099 100644 --- a/app/views/skill_holdings/index.html.erb +++ b/app/views/skill_holdings/index.html.erb @@ -3,7 +3,7 @@ font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-size: 12px; background: #CCCCCC; - margin: 45px; + margin: 40px; width: 480px; border-collapse: collapse; text-align: left; @@ -28,6 +28,9 @@ background: #d0dafd; color: #339; } + h1 { + margin-left: 20px + }

Listing My skills

@@ -47,8 +50,12 @@ <%= link_to 'Remove', user_skill_holding_path(current_user.id, skill_holding.id), confirm: 'Are you sure?', method: :delete %> <% end %> + + + <%= link_to 'New Skill', new_user_skill_holding_path(current_user.id) %> + +
-<%= link_to 'New Skill', new_user_skill_holding_path(current_user.id) %> From 64a414baa3570e230c7f087a5d7780f19e327689 Mon Sep 17 00:00:00 2001 From: beef Date: Sun, 22 Jul 2012 15:07:48 -0500 Subject: [PATCH 17/19] Moved CSS to app/assests/styleshheets folder --- app/assets/stylesheets/application.css | 33 +++++++++++++++++++++ app/views/home/dashboard.html.erb | 38 ++----------------------- app/views/layouts/application.html.erb | 2 +- app/views/skill_holdings/_form.html.erb | 16 +---------- app/views/skill_holdings/index.html.erb | 34 ---------------------- app/views/skills/index.html.erb | 18 ++++++++---- 6 files changed, 49 insertions(+), 92 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index fdca7c0..c17d45e 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -2,3 +2,36 @@ *= require_self *= require_tree . */ + + table { + font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; + font-size: 12px; + background: #CCCCCC; + margin: 40px; + width: 480px; + border-collapse: collapse; + text-align: left; + border-top: 4px solid #aabcfe; + border-bottom: 4px solid #aabcfe; + } + th { + font-size: 13px; + font-weight: normal; + padding: 8px; + background: #b9c9fe; + color: #039; + } + td { + padding: 8px; + background: #e8edff; + border-bottom: 1px solid #fff; + color: #669; + border-top: 1px solid #aabcfe; + } + tr:hover td{ + background: #d0dafd; + color: #339; + } + h1 { + margin-left: 20px + } diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 07e4dce..ce1174b 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -1,38 +1,4 @@ -

Welcome <%= current_user.name %>

@@ -42,12 +8,12 @@ <%= link_to "My skills", user_skill_holdings_path(current_user) %> - All Skills + All Skills FIXME - My Tools + My Tools FIXME <%= link_to "All Tools", tools_path %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bc40e82..22680b5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -39,7 +39,7 @@
- Whos Got What + Whos Got What

<%= render 'shared/flashes' %> diff --git a/app/views/skill_holdings/_form.html.erb b/app/views/skill_holdings/_form.html.erb index bbbbf0c..5b73035 100644 --- a/app/views/skill_holdings/_form.html.erb +++ b/app/views/skill_holdings/_form.html.erb @@ -1,23 +1,9 @@ + <%= form_for([current_user, @skill_holding]) do |sh| %> <% if @skill_holding.errors.any? %>
diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb index 5485099..13f4625 100644 --- a/app/views/skill_holdings/index.html.erb +++ b/app/views/skill_holdings/index.html.erb @@ -1,37 +1,3 @@ -

Listing My skills

diff --git a/app/views/skills/index.html.erb b/app/views/skills/index.html.erb index 88d29ca..9a484ca 100644 --- a/app/views/skills/index.html.erb +++ b/app/views/skills/index.html.erb @@ -1,17 +1,23 @@ +

Listing skills

- - - + + + + <% @skills.each do |skill| %> - - - + + + + <% end %>
NameInterestedKnowledgableActions
<%= link_to 'Show', skill %><%= link_to 'Edit', edit_skill_path(skill) %><%= link_to 'Destroy', skill, confirm: 'Are you sure?', method: :delete %><%= skill.name%>level 0level 1+<%= link_to 'Show', skill %> + <%= link_to 'Edit', edit_skill_path(skill) %> + <%= link_to 'Destroy', skill, confirm: 'Are you sure?', method: :delete %> +
From e5b55c07bbb72ac2b93f69433fccb3592a47fd68 Mon Sep 17 00:00:00 2001 From: beef Date: Sun, 22 Jul 2012 16:43:30 -0500 Subject: [PATCH 18/19] Dashboard redirect if not logged in. --- app/views/home/dashboard.html.erb | 48 +++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index ce1174b..613f332 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -1,24 +1,28 @@ - -

Welcome <%= current_user.name %>

- - - - - - - - - - -
- <%= link_to "My skills", user_skill_holdings_path(current_user) %> - - All Skills FIXME -
- My Tools FIXME - - <%= link_to "All Tools", tools_path %> -
- +<% if current_user == nil %> + Not logged in.
+ <%= link_to "Log in", "/auth/facebook" %> + +<% else %> +

Welcome <%= current_user.name %>

+ + + + + + + + + + +
+ <%= link_to "My skills", user_skill_holdings_path(current_user) %> + + All Skills FIXME +
+ My Tools FIXME + + <%= link_to "All Tools", tools_path %> +
+<% end %> From d8936d0e1542c58baa0459259d90345cd36efa4b Mon Sep 17 00:00:00 2001 From: beef Date: Mon, 23 Jul 2012 06:51:50 -0500 Subject: [PATCH 19/19] minor --- app/views/home/dashboard.html.erb | 3 ++- app/views/skill_holdings/index.html.erb | 2 +- app/views/skills/index.html.erb | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 613f332..3cfb0be 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -12,7 +12,8 @@ <%= link_to "My skills", user_skill_holdings_path(current_user) %> - All Skills FIXME + <%= link_to "All skills", skills_path %> + FIXME diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb index 13f4625..bc892ca 100644 --- a/app/views/skill_holdings/index.html.erb +++ b/app/views/skill_holdings/index.html.erb @@ -1,5 +1,5 @@ -

Listing My skills

+

Listing my skills

diff --git a/app/views/skills/index.html.erb b/app/views/skills/index.html.erb index 9a484ca..d759faf 100644 --- a/app/views/skills/index.html.erb +++ b/app/views/skills/index.html.erb @@ -1,5 +1,5 @@ -

Listing skills

+

Listing all skills

@@ -20,8 +20,10 @@ <% end %> + + + + + +
<%= link_to 'New Skill', new_skill_path %>
- -
- -<%= link_to 'New Skill', new_skill_path %>