-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acd606e
commit e54f7b4
Showing
27 changed files
with
344 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module JobsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" } %> | ||
|
||
|
||
<div class="form-actions"> | ||
<%= f.button :submit, class: "btn btn-primary" %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<tr> | ||
<td><%= job.title %></td> | ||
<td><%= job.description %></td> | ||
<td><%= link_to 'Show', job %></td> | ||
<td><%= link_to 'Edit', edit_job_path(job) %></td> | ||
<td><%= link_to 'Destroy', job, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing job</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @job %> | | ||
<%= link_to 'Back', jobs_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<h1>Job Listings</h1> | ||
|
||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th>Description</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<%= render @jobs %> | ||
</tbody> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Job', new_job_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New job</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', jobs_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="row"> | ||
<div class="span6 offset3"> | ||
<div class="well"> | ||
<p> | ||
<%= @job.title %> | ||
</p> | ||
<p> | ||
<%= @job.description %> | ||
</p> | ||
<%= link_to 'Edit', edit_job_path(@job) %> | | ||
<%= link_to 'Back', jobs_path %> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
<tr> | ||
<td><%= image_tag pin.image(:medium) %></td> | ||
<td><%= pin.description %></td> | ||
<td><%= link_to 'Show', pin %></td> | ||
<% if current_user == pin.user %> | ||
<td><%= link_to 'Edit', edit_pin_path(pin) %></td> | ||
<td><%= link_to 'Destroy', pin, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
<div class="box"> | ||
<%= link_to (image_tag pin.image(:medium)), pin %> | ||
<p class="description"> | ||
<%= pin.description %> | ||
</p> | ||
<p> | ||
<strong> | ||
Posted by <%= pin.user.name %> | ||
</strong> | ||
</p> | ||
<% if current_user == pin.user %> | ||
<p> | ||
<%= link_to 'Edit', edit_pin_path(pin) %> | ||
<%= link_to 'Destroy', pin, method: :delete, data: { confirm: 'Are you sure?' } %> | ||
</p> | ||
<% end %> | ||
</tr> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
<h1>Listing pins</h1> | ||
|
||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Image</th> | ||
<th>Description</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<%= render @pins %> | ||
</tbody> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Pin', new_pin_path %> | ||
<div id="pins"> | ||
<%= render @pins %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
Omrails::Application.routes.draw do | ||
|
||
resources :jobs | ||
|
||
|
||
resources :pins | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddUserIdToJobs < ActiveRecord::Migration | ||
def change | ||
add_column :jobs, :user_id, :integer | ||
add_index :jobs, :user_id | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.