Skip to content

Commit

Permalink
add active flag to table Resume
Browse files Browse the repository at this point in the history
  • Loading branch information
yune committed Aug 24, 2015
1 parent c8fa5fa commit 67a5cf0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/controllers/resume_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def create

def destroy
resume = Resume.find_by(id: params[:id], user_id: current_user.id)
if resume.destroy
resume.active = false
if resume.save
render js: "location.reload();"
else
render js: "alert('delete resume job fail!');"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def destroy
end

def show_resumes
@resumes = Resume.where(user_id: params[:id])
@resumes = Resume.where(user_id: params[:id],active: true)
render 'users/show_resumes.js.erb', layout: "admin"
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable

def hasResume
resumes = Resume.where(user_id: self.id).count
resumes = Resume.where(user_id: self.id, active:true).count
if resumes == 0
return false
else
Expand Down
2 changes: 1 addition & 1 deletion app/views/applications/_choose_resume.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="form-group">
<label class="col-sm-4 control-label">选择简历</label>
<div class="controls col-sm-6">
<%= f.collection_select(:resume_id, Resume.where(user_id: current_user.id), :id, :name,{}, {:class => 'form-control'}) %>
<%= f.collection_select(:resume_id, Resume.where(user_id: current_user.id,active:true), :id, :name,{}, {:class => 'form-control'}) %>
</div>
</div>
<% else %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/my_info/resumes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<div class="panel-body">
<table class="table table-striped">
<% current_user.resumes.each do |r| %>
<% Resume.where(active:true, user_id:current_user.id).each do |r| %>
<tr>
<td><%= t('preview') %>: <%= link_to r.name, "#{Rails.application.config.resumePath}#{r.path}", target: "_blank" %></td>
<td><%= r.created_at.strftime("%Y %b %d") %></td>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20150824122536_add_active_to_resumes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddActiveToResumes < ActiveRecord::Migration
def change
add_column :resumes, :active, :boolean, default: true
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150804040254) do
ActiveRecord::Schema.define(version: 20150824122536) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -218,6 +218,7 @@
t.datetime "updated_at", null: false
t.string "name"
t.boolean "default", default: false
t.boolean "active", default: true
end

create_table "rusumes", force: :cascade do |t|
Expand Down

0 comments on commit 67a5cf0

Please sign in to comment.