Skip to content

Commit

Permalink
long time no push
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcockerham committed Oct 31, 2015
1 parent e17141e commit 064a275
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 18 deletions.
32 changes: 23 additions & 9 deletions app/controllers/certificates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
class CertificatesController < ApplicationController
before_filter :authenticate_user!
#before_filter is_current_user?

# GET /certificates
# GET /certificates.json
def index
#@certificates = Certificate.all
@certificates = current_user.certificates.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @certificates }
Expand All @@ -14,11 +17,13 @@ def index
# GET /certificates/1
# GET /certificates/1.json
def show
@certificate = Certificate.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @certificate }
#@certificates = current_user.certificates.all
#@certificate = @certificates.find(params[:id])
#@certificate = current_user.certificates.all.find(params[:id])
if current_user.id == Certificate.find(params[:id]).user_id
@certificate = Certificate.find(params[:id])
else
redirect_to certificates_url, notice: 'You can only view your own certificates'
end
end

Expand All @@ -34,9 +39,13 @@ def new
end

# GET /certificates/1/edit
def edit
@certificate = Certificate.find(params[:id])
end
#def edit
# if current_user.id == Certificate.find(params[:id]).user_id
# @certificate = Certificate.find(params[:id])
# else
# redirect_to certificates_url, notice: 'You can only edit your own certificates'
# end
# end

# POST /certificates
# POST /certificates.json
Expand Down Expand Up @@ -87,4 +96,9 @@ def destroy
# send_file(pdf_filename, :filename => "19035122-V2W-LFCZ_(1).pdf", :disposition => 'inline', :type => "application/pdf")

#end

#def is_current_user?
# return current_user
#end

end
5 changes: 5 additions & 0 deletions app/controllers/pins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ def destroy
format.json { head :no_content }
end
end

# for rails 4
# def pin_params
# params.require(:pin).permit(:description, :image)
# end
end
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module ApplicationHelper

end
6 changes: 3 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class User < ActiveRecord::Base
:rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :hirer, :job_experience_attributes
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :hirer, :job_experiences_attributes

# Validations
validates_uniqueness_of :email
Expand All @@ -15,12 +15,12 @@ class User < ActiveRecord::Base
has_many :pins, :dependent => :destroy
has_many :job_postings, :dependent => :destroy
has_many :job_applications, :dependent => :destroy
has_one :job_experience, :dependent => :destroy
has_many :job_experiences, :dependent => :destroy

has_many :certificates

# Nested Attributes
accepts_nested_attributes_for :job_experience
accepts_nested_attributes_for :job_experiences, :allow_destroy => true
# :allow_destroy => true,
# :reject_if => :all_blank
end
2 changes: 1 addition & 1 deletion app/views/certificates/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<td><%= certificate.institution %></td>
<td><%= certificate.date_completed %></td>
<td><%= link_to 'Show', certificate %></td>
<td><%= link_to 'Edit', edit_certificate_path(certificate) %></td>
<!-- -->
<td><%= link_to 'Destroy', certificate, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/certificates/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<%= @certificate.date_completed %>
</p>

<%= link_to 'Edit', edit_certificate_path(@certificate) %> |
<!-- -->|
<%= link_to 'Back', certificates_path %>

</div>
Expand Down
5 changes: 3 additions & 2 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<%= f.input :password_confirmation, label: "New Password Confirmation", autocomplete: "off" %>
<%= f.input :current_password %>

<!-- <h2> Job Experience </h2>
<h2> Job Experience </h2>

<% job_experiences = JobExperience.find_all_by_user_id(current_user.id) %>
<% if job_experiences.length == 0 %>
<p>You have not entered any job experiences yet.</p>
Expand All @@ -23,7 +24,7 @@
<% end %>
<% end %>
-->
<%= f.fields_for :job_experience_attributes do |j| %>
<%= f.fields_for :job_experiences do |j| %> <!-- _attributes-->
<%= j.input :company %>
<%= j.input :job_title %>
<%= j.input :description, as: :text, input_html: { rows: "10" } %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ul>
<ul class='nav pull-right'>
<% if user_signed_in? %>
<li><%= link_to "Add Certificate", new_certificate_path %></li>
<li><%= link_to "My Certificates", certificates_path %></li>
<li><%= link_to "Add +", new_pin_path %></li>
<li><%= link_to "Edit Profile", edit_user_registration_path %></li>
<li><%= link_to "Logout", destroy_user_session_path, method: :delete %></li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/pages/about.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>About</h1>
<p>
SkillChest was created for the future of learning and working. Save all of your learning, including non-traditional learning such as conferences and certifications, and keep a verified record all in one place. This can then be share with employers.
SkillChest was created for the future of learning and working. Save all of your learning, including non-traditional learning such as conferences and certifications, and keep a verified record all in one place. This can then be shared with employers.
</p>

0 comments on commit 064a275

Please sign in to comment.