diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 8c515ad..4e97bff 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -12,5 +12,6 @@
//
//= require jquery
//= require jquery_ujs
+//= require jquery.masonry.min.js
//= require bootstrap
//= require_tree .
diff --git a/app/assets/javascripts/jobs.js.coffee b/app/assets/javascripts/jobs.js.coffee
new file mode 100644
index 0000000..7615679
--- /dev/null
+++ b/app/assets/javascripts/jobs.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/app/assets/javascripts/pins.js.coffee b/app/assets/javascripts/pins.js.coffee
index 7615679..7d0be3f 100644
--- a/app/assets/javascripts/pins.js.coffee
+++ b/app/assets/javascripts/pins.js.coffee
@@ -1,3 +1,7 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+
+jQuery ->
+ $('#pins').imagesLoaded ->
+ $('#pins').masonry itemSelector: ".box"
\ No newline at end of file
diff --git a/app/assets/stylesheets/styles.css.scss b/app/assets/stylesheets/styles.css.scss
index 69dcfb3..97f536f 100644
--- a/app/assets/stylesheets/styles.css.scss
+++ b/app/assets/stylesheets/styles.css.scss
@@ -23,4 +23,30 @@ body {
a {
color: $gray;
}
+}
+
+/* Required for jQuery Masonry */
+
+.box {
+ margin: 5px;
+ padding: 5px;
+ font-size: 11px;
+ line-height: 1.4em;
+ float: left;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+ box-shadow: 1px 1px 10px #444;
+ width: 214px;
+}
+
+.box img {
+ width: 100%;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+}
+
+.description {
+ margin: 10px 0 5px;
}
\ No newline at end of file
diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb
new file mode 100644
index 0000000..fb3d17f
--- /dev/null
+++ b/app/controllers/jobs_controller.rb
@@ -0,0 +1,92 @@
+class JobsController < ApplicationController
+ before_filter :authenticate_user!
+
+ # GET /jobs
+ # GET /jobs.json
+ def index
+ @jobs = Job.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @jobs }
+ end
+ end
+
+ # GET /jobs/1
+ # GET /jobs/1.json
+ def show
+ @job = Job.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @job }
+ end
+ end
+
+ # GET /jobs/new
+ # GET /jobs/new.json
+ def new
+ @job = current_user.jobs.new
+ #@job = Job.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @job }
+ end
+ end
+
+ # GET /jobs/1/edit
+ def edit
+ @job = Job.find(params[:id])
+ end
+
+ # POST /jobs
+ # POST /jobs.json
+ def create
+ @job = current_user.jobs.new(params[:job])
+ #@job = Job.new(params[:job])
+
+ respond_to do |format|
+ if @job.user.hirer
+ if @job.save
+ format.html { redirect_to @job, notice: 'Job was successfully created.' }
+ format.json { render json: @job, status: :created, location: @job }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @job.errors, status: :unprocessable_entity }
+ end
+ else
+ format.html { redirect_to @job, notice: 'Only HR members can post jobs.' }
+ format.json { render json: @job.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /jobs/1
+ # PUT /jobs/1.json
+ def update
+ @job = Job.find(params[:id])
+
+ respond_to do |format|
+ if @job.update_attributes(params[:job])
+ format.html { redirect_to @job, notice: 'Job was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @job.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /jobs/1
+ # DELETE /jobs/1.json
+ def destroy
+ @job = Job.find(params[:id])
+ @job.destroy
+
+ respond_to do |format|
+ format.html { redirect_to jobs_url }
+ format.json { head :no_content }
+ end
+ end
+end
diff --git a/app/controllers/pins_controller.rb b/app/controllers/pins_controller.rb
index 41427b6..1cd8fd3 100644
--- a/app/controllers/pins_controller.rb
+++ b/app/controllers/pins_controller.rb
@@ -4,7 +4,8 @@ class PinsController < ApplicationController
# GET /pins
# GET /pins.json
def index
- @pins = Pin.all
+ @pins = Pin.order("created_at desc")
+ #@pins = Pin.all
# @pins = current_user.pins.all
# if @pins.empty?
diff --git a/app/helpers/jobs_helper.rb b/app/helpers/jobs_helper.rb
new file mode 100644
index 0000000..44c7bf6
--- /dev/null
+++ b/app/helpers/jobs_helper.rb
@@ -0,0 +1,2 @@
+module JobsHelper
+end
diff --git a/app/models/job.rb b/app/models/job.rb
new file mode 100644
index 0000000..3fc77d5
--- /dev/null
+++ b/app/models/job.rb
@@ -0,0 +1,18 @@
+class Job < ActiveRecord::Base
+ attr_accessible :description, :title
+
+ belongs_to :user
+
+ validates :description, presence: true, :length => { :maximum => 1000 }
+ validates :title, presence: true
+ validates :user_id, presence: true
+
+ #validates @job.user.hirer = true
+ #with_options :if => :is_hirer? do |hirer|
+ # hirer.validates :password, :length => { :minimum => 10 }
+ #hirer.validates :email, :presence => true
+ #end
+
+ #validates :hirer, :inclusion => { :in => [true, false] }
+ #validates :hirer, presence: true #(user.hirer = true)
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index cb89728..70bdd70 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -9,5 +9,6 @@ class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :hirer
# attr_accessible :title, :body
- has_many :pins
+ has_many :pins, :dependent => :destroy
+ has_many :jobs, :dependent => :destroy
end
diff --git a/app/views/jobs/_form.html.erb b/app/views/jobs/_form.html.erb
new file mode 100644
index 0000000..a4e120f
--- /dev/null
+++ b/app/views/jobs/_form.html.erb
@@ -0,0 +1,11 @@
+<%= simple_form_for(@job, html: { class: "form-horizontal"}) do |f| %>
+ <%= f.error_notification %>
+
+ <%= f.input :title %>
+ <%= f.input :description, as: :text, input_html: { rows: "10" } %>
+
+
+
+ <%= f.button :submit, class: "btn btn-primary" %>
+
+<% end %>
diff --git a/app/views/jobs/_job.html.erb b/app/views/jobs/_job.html.erb
new file mode 100644
index 0000000..db389b6
--- /dev/null
+++ b/app/views/jobs/_job.html.erb
@@ -0,0 +1,7 @@
+
+ <%= job.title %> |
+ <%= job.description %> |
+ <%= link_to 'Show', job %> |
+ <%= link_to 'Edit', edit_job_path(job) %> |
+ <%= link_to 'Destroy', job, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
\ No newline at end of file
diff --git a/app/views/jobs/edit.html.erb b/app/views/jobs/edit.html.erb
new file mode 100644
index 0000000..cb6c58a
--- /dev/null
+++ b/app/views/jobs/edit.html.erb
@@ -0,0 +1,6 @@
+Editing job
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @job %> |
+<%= link_to 'Back', jobs_path %>
diff --git a/app/views/jobs/index.html.erb b/app/views/jobs/index.html.erb
new file mode 100644
index 0000000..17ad18d
--- /dev/null
+++ b/app/views/jobs/index.html.erb
@@ -0,0 +1,21 @@
+Job Listings
+
+
+
+
+ Title |
+ Description |
+ |
+ |
+ |
+
+
+
+
+ <%= render @jobs %>
+
+
+
+
+
+<%= link_to 'New Job', new_job_path %>
diff --git a/app/views/jobs/new.html.erb b/app/views/jobs/new.html.erb
new file mode 100644
index 0000000..9979013
--- /dev/null
+++ b/app/views/jobs/new.html.erb
@@ -0,0 +1,5 @@
+New job
+
+<%= render 'form' %>
+
+<%= link_to 'Back', jobs_path %>
diff --git a/app/views/jobs/show.html.erb b/app/views/jobs/show.html.erb
new file mode 100644
index 0000000..70d7f9b
--- /dev/null
+++ b/app/views/jobs/show.html.erb
@@ -0,0 +1,14 @@
+
+
+
+
+ <%= @job.title %>
+
+
+ <%= @job.description %>
+
+ <%= link_to 'Edit', edit_job_path(@job) %> |
+ <%= link_to 'Back', jobs_path %>
+
+
+
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index 335710b..9e33a68 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -26,12 +26,13 @@
<% end %>
<% if user_signed_in? && current_user.hirer %>
- <%= link_to "Post a Job", job_post_path %>
+ <%= link_to "Post a Job", new_job_path %>
<% end %>
<% if user_signed_in? %>
+ - <%= link_to "Add +", new_pin_path %>
- <%= link_to "Edit Profile", edit_user_registration_path %>
- <%= link_to "Logout", destroy_user_session_path, method: :delete %>
<% else %>
diff --git a/app/views/pins/_pin.html.erb b/app/views/pins/_pin.html.erb
index 45eefe1..6659ffe 100644
--- a/app/views/pins/_pin.html.erb
+++ b/app/views/pins/_pin.html.erb
@@ -1,9 +1,17 @@
-
- <%= image_tag pin.image(:medium) %> |
- <%= pin.description %> |
- <%= link_to 'Show', pin %> |
- <% if current_user == pin.user %>
- <%= link_to 'Edit', edit_pin_path(pin) %> |
- <%= link_to 'Destroy', pin, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <%= link_to (image_tag pin.image(:medium)), pin %>
+
+ <%= pin.description %>
+
+
+
+ Posted by <%= pin.user.name %>
+
+
+ <% if current_user == pin.user %>
+
+ <%= link_to 'Edit', edit_pin_path(pin) %>
+ <%= link_to 'Destroy', pin, method: :delete, data: { confirm: 'Are you sure?' } %>
+
<% end %>
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/pins/index.html.erb b/app/views/pins/index.html.erb
index f64ffa7..7bb9775 100644
--- a/app/views/pins/index.html.erb
+++ b/app/views/pins/index.html.erb
@@ -1,21 +1,3 @@
-Listing pins
-
-
-
-
- Image |
- Description |
- |
- |
- |
-
-
-
-
- <%= render @pins %>
-
-
-
-
-
-<%= link_to 'New Pin', new_pin_path %>
+
+ <%= render @pins %>
+
diff --git a/config/routes.rb b/config/routes.rb
index 07ac0d1..08e4837 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,8 @@
Omrails::Application.routes.draw do
+ resources :jobs
+
+
resources :pins
diff --git a/db/migrate/20130606015341_create_jobs.rb b/db/migrate/20130606015341_create_jobs.rb
new file mode 100644
index 0000000..5c6be86
--- /dev/null
+++ b/db/migrate/20130606015341_create_jobs.rb
@@ -0,0 +1,10 @@
+class CreateJobs < ActiveRecord::Migration
+ def change
+ create_table :jobs do |t|
+ t.string :title
+ t.string :description
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20130606030659_add_user_id_to_jobs.rb b/db/migrate/20130606030659_add_user_id_to_jobs.rb
new file mode 100644
index 0000000..b13f6e8
--- /dev/null
+++ b/db/migrate/20130606030659_add_user_id_to_jobs.rb
@@ -0,0 +1,6 @@
+class AddUserIdToJobs < ActiveRecord::Migration
+ def change
+ add_column :jobs, :user_id, :integer
+ add_index :jobs, :user_id
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e689987..395428a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,17 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130604110107) do
+ActiveRecord::Schema.define(:version => 20130606030659) do
+
+ create_table "jobs", :force => true do |t|
+ t.string "title"
+ t.string "description"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "user_id"
+ end
+
+ add_index "jobs", ["user_id"], :name => "index_jobs_on_user_id"
create_table "pins", :force => true do |t|
t.string "description"
diff --git a/test/fixtures/jobs.yml b/test/fixtures/jobs.yml
new file mode 100644
index 0000000..29fdfad
--- /dev/null
+++ b/test/fixtures/jobs.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ title: MyString
+ description: MyString
+
+two:
+ title: MyString
+ description: MyString
diff --git a/test/functional/jobs_controller_test.rb b/test/functional/jobs_controller_test.rb
new file mode 100644
index 0000000..fb81815
--- /dev/null
+++ b/test/functional/jobs_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class JobsControllerTest < ActionController::TestCase
+ setup do
+ @job = jobs(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:jobs)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create job" do
+ assert_difference('Job.count') do
+ post :create, job: { description: @job.description, title: @job.title }
+ end
+
+ assert_redirected_to job_path(assigns(:job))
+ end
+
+ test "should show job" do
+ get :show, id: @job
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @job
+ assert_response :success
+ end
+
+ test "should update job" do
+ put :update, id: @job, job: { description: @job.description, title: @job.title }
+ assert_redirected_to job_path(assigns(:job))
+ end
+
+ test "should destroy job" do
+ assert_difference('Job.count', -1) do
+ delete :destroy, id: @job
+ end
+
+ assert_redirected_to jobs_path
+ end
+end
diff --git a/test/unit/helpers/jobs_helper_test.rb b/test/unit/helpers/jobs_helper_test.rb
new file mode 100644
index 0000000..7c4a3fd
--- /dev/null
+++ b/test/unit/helpers/jobs_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class JobsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/job_test.rb b/test/unit/job_test.rb
new file mode 100644
index 0000000..5079316
--- /dev/null
+++ b/test/unit/job_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class JobTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/vendor/assets/javascripts/jquery.masonry.min.js b/vendor/assets/javascripts/jquery.masonry.min.js
new file mode 100644
index 0000000..57c081c
--- /dev/null
+++ b/vendor/assets/javascripts/jquery.masonry.min.js
@@ -0,0 +1,10 @@
+/**
+ * jQuery Masonry v2.1.08
+ * A dynamic layout plugin for jQuery
+ * The flip-side of CSS Floats
+ * http://masonry.desandro.com
+ *
+ * Licensed under the MIT license.
+ * Copyright 2012 David DeSandro
+ */
+(function(e,t,n){"use strict";var r=t.event,i;r.special.smartresize={setup:function(){t(this).bind("resize",r.special.smartresize.handler)},teardown:function(){t(this).unbind("resize",r.special.smartresize.handler)},handler:function(e,t){var n=this,s=arguments;e.type="smartresize",i&&clearTimeout(i),i=setTimeout(function(){r.dispatch.apply(n,s)},t==="execAsap"?0:100)}},t.fn.smartresize=function(e){return e?this.bind("smartresize",e):this.trigger("smartresize",["execAsap"])},t.Mason=function(e,n){this.element=t(n),this._create(e),this._init()},t.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1,containerStyle:{position:"relative"}},t.Mason.prototype={_filterFindBricks:function(e){var t=this.options.itemSelector;return t?e.filter(t).add(e.find(t)):e},_getBricks:function(e){var t=this._filterFindBricks(e).css({position:"absolute"}).addClass("masonry-brick");return t},_create:function(n){this.options=t.extend(!0,{},t.Mason.settings,n),this.styleQueue=[];var r=this.element[0].style;this.originalStyle={height:r.height||""};var i=this.options.containerStyle;for(var s in i)this.originalStyle[s]=r[s]||"";this.element.css(i),this.horizontalDirection=this.options.isRTL?"right":"left";var o=this.element.css("padding-"+this.horizontalDirection),u=this.element.css("padding-top");this.offset={x:o?parseInt(o,10):0,y:u?parseInt(u,10):0},this.isFluid=this.options.columnWidth&&typeof this.options.columnWidth=="function";var a=this;setTimeout(function(){a.element.addClass("masonry")},0),this.options.isResizable&&t(e).bind("smartresize.masonry",function(){a.resize()}),this.reloadItems()},_init:function(e){this._getColumns(),this._reLayout(e)},option:function(e,n){t.isPlainObject(e)&&(this.options=t.extend(!0,this.options,e))},layout:function(e,t){for(var n=0,r=e.length;n