Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fully backboned application #1

Merged
merged 9 commits into from about 1 year ago

1 participant

kerrieyee
kerrieyee
Owner

No description provided.

kerrieyee kerrieyee merged commit 6ab2ecf into from February 05, 2013
kerrieyee kerrieyee closed this February 05, 2013
kerrieyee kerrieyee deleted the branch February 05, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 36 changed files with 302 additions and 173 deletions. Show diff stats Hide diff stats

  1. 1  Gemfile
  2. 12  Gemfile.lock
  3. 8  app/assets/javascripts/application.js
  4. 5  app/assets/javascripts/collections/job_prospects.js.coffee
  5. 11  app/assets/javascripts/job_org.js.coffee
  6. 1  app/assets/javascripts/job_prospects.js
  7. 1  app/assets/javascripts/models/job_prospect.js.coffee
  8. 14  app/assets/javascripts/routers/job_prospects_router.js.coffee
  9. 47  app/assets/javascripts/views/job_prospects/job_prospect.js.coffee
  10. 71  app/assets/javascripts/views/job_prospects/job_prospects_index.js.coffee
  11. 3  app/assets/stylesheets/main.css.scss
  12. 30  app/assets/templates/job_prospects/index.jst.eco
  13. 6  app/assets/templates/job_prospects/job_prospect.jst.eco
  14. 6  app/controllers/events_controller.rb
  15. 55  app/controllers/job_prospects_controller.rb
  16. 4  app/controllers/main_controller.rb
  17. 2  app/helpers/main_helper.rb
  18. 3  app/models/event.rb
  19. 11  app/models/job_prospect.rb
  20. 15  app/views/job_prospects/_form.html.erb
  21. 6  app/views/job_prospects/_job_prospect.html.erb
  22. 25  app/views/job_prospects/create.js.erb
  23. 8  app/views/job_prospects/destroy.js.erb
  24. 12  app/views/job_prospects/edit.js.erb
  25. 22  app/views/job_prospects/index.html.erb
  26. 4  app/views/job_prospects/new.js.erb
  27. 20  app/views/job_prospects/update.js.erb
  28. 8  app/views/layouts/_navigation.html.erb
  29. 7  app/views/layouts/application.html.erb
  30. 1  app/views/main/index.html.erb
  31. 8  config/routes.rb
  32. 9  db/migrate/20130205064309_add_last_updatedto_job_prospects.rb
  33. 7  db/schema.rb
  34. 12  spec/controllers/main_controller_spec.rb
  35. 15  spec/helpers/main_helper_spec.rb
  36. 5  spec/views/main/index.html.erb_spec.rb
1  Gemfile
@@ -45,6 +45,7 @@ group :production do
45 45
 end
46 46
 
47 47
 gem 'will_paginate', '~> 3.0.0'
  48
+gem 'backbone-on-rails'
48 49
 gem 'jquery-rails'
49 50
 gem "therubyracer"
50 51
 gem "less-rails"
12  Gemfile.lock
@@ -39,6 +39,11 @@ GEM
39 39
       multi_json (~> 1.0)
40 40
     addressable (2.3.2)
41 41
     arel (3.0.2)
  42
+    backbone-on-rails (0.9.10.0)
  43
+      eco
  44
+      ejs
  45
+      jquery-rails
  46
+      rails (>= 3.1)
42 47
     bcrypt-ruby (3.0.1)
43 48
     bourne (1.1.2)
44 49
       mocha (= 0.10.5)
@@ -77,6 +82,12 @@ GEM
77 82
       railties (~> 3.1)
78 83
       warden (~> 1.2.1)
79 84
     diff-lcs (1.1.3)
  85
+    eco (1.0.0)
  86
+      coffee-script
  87
+      eco-source
  88
+      execjs
  89
+    eco-source (1.1.0.rc.1)
  90
+    ejs (1.1.1)
80 91
     erubis (2.7.0)
81 92
     eventmachine (1.0.0)
82 93
     execjs (1.4.0)
@@ -243,6 +254,7 @@ PLATFORMS
243 254
   ruby
244 255
 
245 256
 DEPENDENCIES
  257
+  backbone-on-rails
246 258
   capybara
247 259
   coffee-rails (~> 3.2.1)
248 260
   database_cleaner
8  app/assets/javascripts/application.js
@@ -13,4 +13,12 @@
13 13
 //= require jquery
14 14
 //= require jquery_ujs
15 15
 //= require twitter/bootstrap
  16
+//= require underscore
  17
+//= require backbone
  18
+//= require job_org
  19
+//= require_tree ../templates
  20
+//= require_tree ./models
  21
+//= require_tree ./collections
  22
+//= require_tree ./views
  23
+//= require_tree ./routers
16 24
 //= require_tree .
5  app/assets/javascripts/collections/job_prospects.js.coffee
... ...
@@ -0,0 +1,5 @@
  1
+class JobOrg.Collections.JobProspects extends Backbone.Collection
  2
+
  3
+  model: JobOrg.Models.JobProspect
  4
+
  5
+  url: '/api/job_prospects'
11  app/assets/javascripts/job_org.js.coffee
... ...
@@ -0,0 +1,11 @@
  1
+window.JobOrg =
  2
+  Models: {}
  3
+  Collections: {}
  4
+  Views: {}
  5
+  Routers: {}
  6
+  initialize: -> 
  7
+  	new JobOrg.Routers.JobProspects()
  8
+  	Backbone.history.start()
  9
+
  10
+$(document).ready ->
  11
+  JobOrg.initialize()
1  app/assets/javascripts/job_prospects.js
... ...
@@ -1 +0,0 @@
1  
-
1  app/assets/javascripts/models/job_prospect.js.coffee
... ...
@@ -0,0 +1 @@
  1
+class JobOrg.Models.JobProspect extends Backbone.Model
14  app/assets/javascripts/routers/job_prospects_router.js.coffee
... ...
@@ -0,0 +1,14 @@
  1
+class JobOrg.Routers.JobProspects extends Backbone.Router
  2
+
  3
+  routes: 
  4
+    '': 'index'
  5
+  
  6
+  initialize: ->
  7
+    @collection = new JobOrg.Collections.JobProspects()
  8
+    @collection.fetch()
  9
+    @collection.comparator = (item) ->
  10
+      item.get("last_updated")
  11
+
  12
+  index: ->
  13
+    view = new JobOrg.Views.JobProspectsIndex(collection: @collection)
  14
+    $('#container').html(view.render().el)
47  app/assets/javascripts/views/job_prospects/job_prospect.js.coffee
... ...
@@ -0,0 +1,47 @@
  1
+class JobOrg.Views.JobProspect extends Backbone.View
  2
+
  3
+  template: JST['job_prospects/job_prospect']
  4
+  tagName: 'tr'
  5
+
  6
+  events:
  7
+    'click input[value="Delete"]': 'removeJobProspect'
  8
+    'click input[value="Edit"]': 'editJobProspect'
  9
+
  10
+  initialize: ->
  11
+    @model.on('destroy', @unrenderJobProspect, this)
  12
+    @model.on('save', @rerenderJobProspect, this)
  13
+
  14
+  render: ->
  15
+    $(@el).html(@template(job_prospect: @model))
  16
+    this
  17
+
  18
+  removeJobProspect: (event, job_prospect) ->
  19
+    event.preventDefault
  20
+    @model.destroy()
  21
+
  22
+  editJobProspect: (event, job_prospect) ->
  23
+    event.preventDefault()
  24
+    $('form#new_job_prospect').hide()
  25
+    $('form#edit_job_prospect').show()
  26
+    $('#edit_job_prospect_company').val(@model.get('company'))
  27
+    $('#edit_job_prospect_position').val(@model.get('position'))
  28
+    $('#edit_id').val(@model.get('id'))
  29
+  
  30
+  handleError: (job_prospect, response) ->
  31
+    if response.status == 422
  32
+      errors = $.parseJSON(response.responseText).errors
  33
+      for attribute, messages of errors
  34
+        for message in messages
  35
+          $('.alert-error').text("#{attribute} #{message}.")
  36
+          $('.alert-error').show()
  37
+          $('.alert-success').hide()
  38
+          $('.alert-warning').hide()
  39
+          $('.alert-notice').hide()
  40
+
  41
+  rerenderJobProspect: ->
  42
+    $(@el).html(@template(job_prospect: @model))
  43
+    this
  44
+
  45
+  unrenderJobProspect: ->
  46
+    $(@el).remove()
  47
+    
71  app/assets/javascripts/views/job_prospects/job_prospects_index.js.coffee
... ...
@@ -0,0 +1,71 @@
  1
+class JobOrg.Views.JobProspectsIndex extends Backbone.View
  2
+
  3
+  template: JST['job_prospects/index']
  4
+
  5
+  events:
  6
+    'submit #new_job_prospect': 'createJobProspect'
  7
+    'click input[value="Update Job Prospect"]': 'updateJobProspect'
  8
+
  9
+
  10
+  initialize: ->
  11
+    @collection.on('reset', @render, this)
  12
+    @collection.on('add', @appendJobProspect, this)
  13
+
  14
+  render: ->
  15
+    $(@el).html(@template())
  16
+    @collection.each(@appendJobProspect)
  17
+    this
  18
+
  19
+  appendJobProspect: (job_prospect)=>
  20
+    view = new JobOrg.Views.JobProspect(model: job_prospect)
  21
+    @$('#jobprospects').prepend(view.render().el)
  22
+
  23
+  createJobProspect: (event) ->
  24
+    event.preventDefault()
  25
+    attributes =
  26
+      company: $('#new_job_prospect_company').val()
  27
+      position: $('#new_job_prospect_position').val()
  28
+    @collection.create attributes,
  29
+      wait: true
  30
+      success: ->
  31
+        $('#new_job_prospect')[0].reset()
  32
+        $('.alert-success').text "Your job prospect has been successfully created."
  33
+        $('.alert-error').hide()
  34
+        $('.alert-success').show()
  35
+        $('.alert-warning').hide()
  36
+        $('.alert-notice').hide()
  37
+      error: @handleError
  38
+  
  39
+  updateJobProspect: (event, job_prospect) ->
  40
+    event.preventDefault()
  41
+    attributes =
  42
+      company: $('#edit_job_prospect_company').val()
  43
+      position: $('#edit_job_prospect_position').val()
  44
+    editJob = @collection.get($('#edit_id').val())
  45
+    editJob.set attributes
  46
+    editJob.save attributes,
  47
+      wait: true
  48
+      success: ->
  49
+        $('#edit_job_prospect')[0].reset()
  50
+        $('#edit_job_prospect').hide()
  51
+        $('#new_job_prospect').show()
  52
+        $('.alert-success').text "Your job prospect has been successfully updated."
  53
+        $('.alert-error').hide()
  54
+        $('.alert-success').show()
  55
+        $('.alert-warning').hide()
  56
+        $('.alert-notice').hide()
  57
+        editJob.trigger("save")
  58
+      error: @handleError
  59
+
  60
+  handleError: (job_prospect, response) ->
  61
+    if response.status == 422
  62
+      errors = $.parseJSON(response.responseText).errors
  63
+      for attribute, messages of errors
  64
+        for message in messages
  65
+          $('.alert-error').text("#{attribute} #{message}.")
  66
+          $('.alert-error').show()
  67
+          $('.alert-success').hide()
  68
+          $('.alert-warning').hide()
  69
+          $('.alert-notice').hide()
  70
+      
  71
+      
3  app/assets/stylesheets/main.css.scss
... ...
@@ -0,0 +1,3 @@
  1
+// Place all the styles related to the main controller here.
  2
+// They will automatically be included in application.css.
  3
+// You can use Sass (SCSS) here: http://sass-lang.com/
30  app/assets/templates/job_prospects/index.jst.eco
... ...
@@ -0,0 +1,30 @@
  1
+<h1>Job Prospects</h1>
  2
+<form id="new_job_prospect">
  3
+	Company:</br>
  4
+	<input type="text" name="company" id="new_job_prospect_company"><br/>
  5
+	Position:</br>
  6
+	<input type="text" name="position" id="new_job_prospect_position"><br/>
  7
+	<input type="submit" value="Add" class="btn btn-small btn-info">
  8
+</form>
  9
+<form id="edit_job_prospect" style="display:none">
  10
+	Company:</br>
  11
+	<input type="text" name="company" id="edit_job_prospect_company"><br/>
  12
+	Position:</br>
  13
+	<input type="text" name="position" id="edit_job_prospect_position"><br/>
  14
+	<input type="hidden" name="id" id="edit_id">
  15
+	<input type="submit" value="Update Job Prospect" class="btn btn-small btn-info">
  16
+</form>
  17
+<table class="table">
  18
+	<thead>
  19
+		<tr> 
  20
+			<th> Company </th>
  21
+			<th> Position </th>
  22
+			<th> Edit </th>
  23
+			<th> Delete </th>
  24
+			<th> Last Updated </th>
  25
+		</tr>
  26
+	</thead>
  27
+	<tbody id="jobprospects">
  28
+		
  29
+	</tbody>
  30
+</table>
6  app/assets/templates/job_prospects/job_prospect.jst.eco
... ...
@@ -0,0 +1,6 @@
  1
+	<td><a href="/job_prospects/<%=@job_prospect.get('id')%>"> <%= @job_prospect.get('company') %></a></td>
  2
+	<td><%= @job_prospect.get('position') %></td>
  3
+	<td><input type="button" value="Edit" class="btn btn-small btn-info edit_job_prospect%>"></td>
  4
+	<td><input type="button" value="Delete" class="btn btn-small btn-warning"></td>
  5
+	<td><%= @job_prospect.get('updated_at')[5..6] + '/' + @job_prospect.get('updated_at')[8..9] + '/' + @job_prospect.get('updated_at')[0..3] + " - " + @job_prospect.get('updated_at')[11..15]%></td>
  6
+
6  app/controllers/events_controller.rb
@@ -24,7 +24,8 @@ def new
24 24
 	def create
25 25
 		job_prospect = {:job_prospect => JobProspect.find(params[:job_prospect_id])}
26 26
 		@event = Event.create(params[:event].merge(job_prospect))
27  
-
  27
+		@event.job_prospect.last_updated = Time.now
  28
+		@event.job_prospect.save
28 29
 		if @event.save
29 30
 			flash[:success] = "Your event has been saved."
30 31
 			redirect_to job_prospect_events_path
@@ -47,7 +48,8 @@ def edit
47 48
 	def update
48 49
 		@event = Event.find(params[:id])
49 50
 		job_prospect = {:job_prospect => @event.job_prospect}
50  
-
  51
+		@event.job_prospect.last_updated = Time.now
  52
+		@event.job_prospect.save
51 53
 	  if @event.update_attributes(params[:event].merge(job_prospect))
52 54
 	  	flash[:success] = "Your event has been successfully updated!"
53 55
 	   	redirect_to job_prospect_events_path(@event.job_prospect)
55  app/controllers/job_prospects_controller.rb
... ...
@@ -1,60 +1,31 @@
1 1
 class JobProspectsController < ApplicationController
  2
+	respond_to :json, :html
2 3
 	def index
3  
-		@job_prospects = JobProspect.paginate(:page => params[:page],
4  
-                           :per_page   => 8,
5  
-                           :order      => 'created_at DESC',
6  
-                           :conditions => { :user_id => current_user.id })
7  
-		@job_prospect=JobProspect.new
8  
-	end
9  
-
10  
-	def new
11  
-		@job_prospect=JobProspect.new
12  
-		respond_to do |format| 
13  
-			format.html { render :action => "new" }
14  
-			format.js
15  
-		end
  4
+		@job_prospects = JobProspect.where(:user_id => current_user.id)
  5
+		respond_with @job_prospects
16 6
 	end
17 7
 
18  
-
19 8
 	def create
20  
-		@job_prospects = JobProspect.where(:user_id => current_user.id)
21  
-		@job_prospect = JobProspect.new(	:company => params[:job_prospect][:company],
  9
+		@job_prospect = JobProspect.create(	:company => params[:job_prospect][:company],
22 10
 																			:position => params[:job_prospect][:position],
23 11
 																			:user => current_user)
24  
-		respond_to do |format|
25  
-			if @job_prospect.save
26  
-				format.html{redirect_to job_prospects_url}
27  
-				format.js
28  
-			else
29  
-				format.html{ render :action => "create"}
30  
-				format.js
31  
-     end			
32  
-		end
  12
+		respond_with @job_prospect
33 13
 	end
34 14
 
35  
-	def edit
36  
-		@job_prospect = JobProspect.find(params[:id])
37  
-		respond_to { |format| format.js }
38  
-	end 
39  
-
40 15
 	def update
41 16
 		@job_prospect = JobProspect.find(params[:id])
  17
+		@job_prospect.update_attributes(:company => params[:job_prospect][:company],
  18
+																			:position => params[:job_prospect][:position],
  19
+																			:user => current_user)
42 20
 
43  
-		respond_to do |format|
44  
-			if @job_prospect.update_attributes(params[:job_prospect])
45  
-				format.html{redirect_to job_prospects_url}
46  
-				format.js
47  
-			else
48  
-				format.html{ render :action => "edit"}
49  
-				format.js
50  
-     	end			
51  
-		end
  21
+		respond_with(@job_prospect)
52 22
 	end
53 23
 
54 24
 	def show
55 25
 		@job_prospect = JobProspect.find_by_id_and_user_id(params[:id], current_user.id)
56 26
 		if @job_prospect
57 27
 			@events = Event.where(:job_prospect_id => @job_prospect.id).order("conversation_date").limit(5)
  28
+			respond_with(@job_prospect, @events)
58 29
 		else
59 30
 			redirect_unauthorized_user
60 31
 		end
@@ -62,11 +33,7 @@ def show
62 33
 
63 34
 	def destroy
64 35
 		@job_prospect = JobProspect.find(params[:id])
65  
-		@job_prospect.destroy
66  
-		respond_to do |format|
67  
-			format.html{redirect_to job_prospects_url}
68  
-			format.js
69  
-		end
  36
+		respond_with(@job_prospect.destroy)
70 37
 	end
71 38
 
72 39
 end
4  app/controllers/main_controller.rb
... ...
@@ -0,0 +1,4 @@
  1
+class MainController < ApplicationController
  2
+  def index
  3
+  end
  4
+end
2  app/helpers/main_helper.rb
... ...
@@ -0,0 +1,2 @@
  1
+module MainHelper
  2
+end
3  app/models/event.rb
... ...
@@ -1,5 +1,6 @@
1 1
 class Event < ActiveRecord::Base
2  
-  attr_accessible :contact, :contact_info, :conversation_date, :job_prospect, :notes, :conversation_time, :conversation_type
  2
+  attr_accessible :contact, :contact_info, :conversation_date, :job_prospect, 
  3
+  								:notes, :conversation_time, :conversation_type, :updated_at
3 4
   validates :contact, :contact_info, :conversation_date, :job_prospect, presence: true
4 5
   belongs_to :job_prospect
5 6
 end
11  app/models/job_prospect.rb
... ...
@@ -1,8 +1,17 @@
1 1
 class JobProspect < ActiveRecord::Base
2  
-  attr_accessible :company, :position, :user
  2
+  attr_accessible :company, :position, :user, :last_updated
3 3
 
  4
+  before_create :set_last_updated_to_now
  5
+  before_update :set_last_updated_to_now
4 6
   validates :company, :user, presence: true
5 7
 
6 8
   belongs_to :user
7 9
   has_many :events, :dependent => :destroy
  10
+
  11
+  
  12
+
  13
+  def set_last_updated_to_now
  14
+    self.last_updated = Time.now
  15
+  end
  16
+
8 17
 end
15  app/views/job_prospects/_form.html.erb
... ...
@@ -1,15 +0,0 @@
1  
-<%= form_for @job_prospect, remote: true do |f| %>
2  
-	<div class="control-group">
3  
-		<%=f.label :company%>
4  
-		<div class="controls">
5  
-			<%=f.text_field :company%>
6  
-		</div>
7  
-	</div>
8  
-	<div class="control-group">
9  
-		<%=f.label :position%>
10  
-		<div class="controls">
11  
-			<%=f.text_field :position%>
12  
-		</div>
13  
-	</div>
14  
-	<%=f.submit :class => "btn btn-info"%>
15  
-<%end%>
6  app/views/job_prospects/_job_prospect.html.erb
... ...
@@ -1,6 +0,0 @@
1  
-<tr id="<%=job_prospect.id%>" >
2  
-	<td id="company"><%= link_to "#{job_prospect.company}", job_prospect_path(job_prospect)%></td>
3  
-	<td><%= job_prospect.position%></td>
4  
-	<td><%= link_to "Edit", edit_job_prospect_path(job_prospect), :remote => true, :class => "btn btn-small btn-info"%>
5  
-	<td><%= link_to "Delete", job_prospect_path(job_prospect), :confirm => "Are you sure? This will delete all events for this company as well.", :method => :delete, :remote => true, :class => "btn btn-small btn-warning" %>
6  
-</tr>
25  app/views/job_prospects/create.js.erb
... ...
@@ -1,25 +0,0 @@
1  
-
2  
-$('.errors').hide();
3  
-<% if @job_prospect.errors.any? %>
4  
-  var errors = $('<ul />');
5  
-  <% @job_prospect.errors.full_messages.each do |error| %>
6  
-    errors.append('<li><%= escape_javascript(error) %></li>');
7  
-  <% end %>
8  
-  $('.errors').html(errors);
9  
-  $('.errors').fadeIn('slow');
10  
-  // something to try later can listen for all errors from this page to get output so don't have to ping server and errors are all clientside
11  
-<%else%>
12  
-	
13  
-	$('table#job_prospects_list thead').after("<%= j render @job_prospect%>");
14  
-	$('input#job_prospect_company').val("");
15  
-	$('input#job_prospect_position').val("");
16  
-
17  
-	$('.create-job-prospect-success').html('\n Job Prospect has been successfully added!');
18  
-	$('.create-job-prospect-success').fadeIn('slow');
19  
-	$('.create-job-prospect-success').fadeOut('slow');
20  
-	$('.form').hide();
21  
-	$('.new_job_prospect_button').show();
22  
-
23  
-<%end%>
24  
-
25  
-
8  app/views/job_prospects/destroy.js.erb
... ...
@@ -1,8 +0,0 @@
1  
-$('.alert').hide();
2  
-$('.errors').hide();
3  
-$('#<%=@job_prospect.id%>').fadeOut();
4  
-
5  
-var close = '<a class = "close" data-dismiss="alert">&#215;</a>';
6  
-$('.delete-job-prospect-success').html(close + '\n Job Prospect has been successfully deleted!');
7  
-$('.delete-job-prospect-success').fadeIn('slow');
8  
-$('.delete-job-prospect-success').fadeOut('slow');
12  app/views/job_prospects/edit.js.erb
... ...
@@ -1,12 +0,0 @@
1  
-$('.alert').hide();
2  
-$('form.new_job_prospect').replaceWith("<%= j render(:partial=> 'form', :locals =>{:job_prospect=> @job_prospect})%>")
3  
-$('.form').show();
4  
-$('input#job_prospect_company').val("<%=@job_prospect.company%>");
5  
-$('input#job_prospect_position').val("<%=@job_prospect.position%>");
6  
-$('.new_job_prospect_button').hide();
7  
-
8  
-// instead of this could always do everything clientside where you would keep the same form 
9  
-// no hiding or showing that would just use js to rerender the action
10  
-// this would allow the form to be created purely server side
11  
-// The third option would be to creat two separate forms for edit and new and toggle the two forms.
12  
-
22  app/views/job_prospects/index.html.erb
... ...
@@ -1,22 +0,0 @@
1  
-<h1><%= current_user.name%>'s Job Prospects </h1>
2  
-<%= link_to "New Job Propsect", new_job_prospect_path, :remote => true, :method => "get", :class => "btn btn-info new_job_prospect_button offset1" %>
3  
-<div class="form offset1" style = "display: none;">
4  
-	<%=render 'form'%>
5  
-</div>
6  
-
7  
-<table class="table span8 offset1" id="job_prospects_list">
8  
-	<thead>
9  
-		<tr>
10  
-			<th> Company </th>
11  
-			<th> Position Applied For</th>
12  
-		</tr>
13  
-	</thead>
14  
-	<tbody>
15  
-		<% @job_prospects.each do |job_prospect| %>
16  
-			<%= render job_prospect %>
17  
-		<%end%>
18  
-	</tbody>
19  
-</table>
20  
-
21  
-<%= will_paginate @job_prospects %>
22  
-
4  app/views/job_prospects/new.js.erb
... ...
@@ -1,4 +0,0 @@
1  
-$('div.alert-notice').hide();
2  
-$('form.edit_job_prospect').replaceWith("<%= j render(:partial=> 'form', :locals =>{:job_prospect=> @job_prospect})%>")
3  
-$('.form').show();
4  
-$('.new_job_prospect_button').hide();
20  app/views/job_prospects/update.js.erb
... ...
@@ -1,20 +0,0 @@
1  
-$('.errors').hide();
2  
-<% if @job_prospect.errors.any? %>
3  
-  var errors = $('<ul />');
4  
-  <% @job_prospect.errors.full_messages.each do |error| %>
5  
-    errors.append('<li><%= escape_javascript(error) %></li>');
6  
-  <% end %>
7  
-  $('.errors').html(errors);
8  
-  $('.errors').fadeIn('slow');
9  
-<%else%>
10  
-	$('table#job_prospects_list tbody tr#<%=@job_prospect.id%>').replaceWith("<%= j render(:partial=> 'job_prospect', :locals =>{:job_prospect=> @job_prospect})%>");
11  
-	$('input#job_prospect_company').val("");
12  
-	$('input#job_prospect_position').val("");
13  
-
14  
-	$('.create-job-prospect-success').html('\n Job Prospect has been successfully updated!');
15  
-	$('.create-job-prospect-success').fadeIn('slow');
16  
-	$('.create-job-prospect-success').fadeOut('slow');
17  
-	$('.form').hide();
18  
-	$('.new_job_prospect_button').show();
19  
-// hide form and then show button for adding a new role
20  
-<%end%>
8  app/views/layouts/_navigation.html.erb
@@ -5,10 +5,10 @@
5 5
       <div class="container nav-collapse">
6 6
         <% if user_signed_in? %>
7 7
           <ul class="nav pull-right">
8  
-            <li><%= link_to "Job Prospects", job_prospects_path  %></li>
9  
-             <li><%= link_to "All Events", all_events_path  %></li>
10  
-             <li><%= link_to "Sign Out", destroy_user_session_path, :method => :delete %></li>
11  
-             <li><%= link_to "Profile", edit_user_registration_path %></li>
  8
+            <li><%= link_to "Job Prospects", root_path  %></li>
  9
+            <li><%= link_to "All Events", all_events_path  %></li>
  10
+            <li><%= link_to "Profile", edit_user_registration_path %></li>
  11
+            <li><%= link_to "Sign Out", destroy_user_session_path, :method => :delete %></li>
12 12
           </ul>
13 13
         <% else %>
14 14
           <ul class="nav pull-right">
7  app/views/layouts/application.html.erb
@@ -11,10 +11,9 @@
11 11
 	<div class="container" >
12 12
 		<div class="row">
13 13
 			<div class="errors-alerts span10 offset1">
14  
-				<div class="alert alert-warning delete-event-success" style = "display: none;"></div>
15  
-				<div class="alert alert-error errors" style = "display: none;"></div>
16  
-				<div class="alert alert-success create-job-prospect-success" style = "display: none;"></div>
17  
-				<div class="alert alert-success delete-job-prospect-success" style = "display: none;"></div>
  14
+				<div class="alert alert-warning" style = "display: none;"></div>
  15
+				<div class="alert alert-error" style = "display: none;"></div>
  16
+				<div class="alert alert-success" style = "display: none;"></div>
18 17
 				<% flash.each do |key, value| %>
19 18
 					<%= content_tag(:div, value, class: "alert alert-#{key}")%>
20 19
 				<%end%>
1  app/views/main/index.html.erb
... ...
@@ -0,0 +1 @@
  1
+<div id="container">Loading...</div>
8  config/routes.rb
... ...
@@ -1,7 +1,13 @@
1 1
 JobOrg::Application.routes.draw do
  2
+
2 3
   devise_for :users
3 4
 
4  
-  root :to => "job_prospects#index"
  5
+  root :to => "main#index"
  6
+
  7
+  scope "api" do
  8
+    resources :job_prospects
  9
+  end
  10
+
5 11
   resources :job_prospects do
6 12
     resources :events
7 13
   end
9  db/migrate/20130205064309_add_last_updatedto_job_prospects.rb
... ...
@@ -0,0 +1,9 @@
  1
+class AddLastUpdatedtoJobProspects < ActiveRecord::Migration
  2
+  def up
  3
+  	add_column :job_prospects, :last_updated, :timestamp
  4
+  end
  5
+
  6
+  def down
  7
+  	remove_column :job_prospects, :last_updated
  8
+  end
  9
+end
7  db/schema.rb
@@ -11,7 +11,7 @@
11 11
 #
12 12
 # It's strongly recommended to check this file into your version control system.
13 13
 
14  
-ActiveRecord::Schema.define(:version => 20130114073825) do
  14
+ActiveRecord::Schema.define(:version => 20130205064309) do
15 15
 
16 16
   create_table "events", :force => true do |t|
17 17
     t.string   "contact"
@@ -31,8 +31,9 @@
31 31
     t.string   "company"
32 32
     t.string   "position"
33 33
     t.integer  "user_id"
34  
-    t.datetime "created_at", :null => false
35  
-    t.datetime "updated_at", :null => false
  34
+    t.datetime "created_at",   :null => false
  35
+    t.datetime "updated_at",   :null => false
  36
+    t.datetime "last_updated"
36 37
   end
37 38
 
38 39
   add_index "job_prospects", ["user_id"], :name => "index_job_prospects_on_user_id"
12  spec/controllers/main_controller_spec.rb
... ...
@@ -0,0 +1,12 @@
  1
+require 'spec_helper'
  2
+
  3
+describe MainController do
  4
+
  5
+  describe "GET 'index'" do
  6
+    it "returns http success" do
  7
+      get 'index'
  8
+      response.should be_success
  9
+    end
  10
+  end
  11
+
  12
+end
15  spec/helpers/main_helper_spec.rb
... ...
@@ -0,0 +1,15 @@
  1
+require 'spec_helper'
  2
+
  3
+# Specs in this file have access to a helper object that includes
  4
+# the MainHelper. For example:
  5
+#
  6
+# describe MainHelper do
  7
+#   describe "string concat" do
  8
+#     it "concats two strings with spaces" do
  9
+#       helper.concat_strings("this","that").should == "this that"
  10
+#     end
  11
+#   end
  12
+# end
  13
+describe MainHelper do
  14
+  pending "add some examples to (or delete) #{__FILE__}"
  15
+end
5  spec/views/main/index.html.erb_spec.rb
... ...
@@ -0,0 +1,5 @@
  1
+require 'spec_helper'
  2
+
  3
+describe "main/index.html.erb" do
  4
+  pending "add some examples to (or delete) #{__FILE__}"
  5
+end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.