Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User can add skills and jobs #4

Merged
merged 3 commits into from
Oct 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions linkedout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ def default_user
redirect "/"
end

post "/jobs" do
job_attrs = params[:job]
job_attrs.merge!({ :user => default_user })

job = Job.new(job_attrs)
job.save

redirect "/"
end

put "/jobs/edit" do
job_attrs = params[:job]

Expand All @@ -51,6 +61,16 @@ def default_user
redirect "/"
end

post "/skills" do
skill_attrs = params[:skill]
skill_attrs.merge!({ :user => default_user })

skill = Skill.new(skill_attrs)
skill.save

redirect "/"
end

put "/skills/edit" do
skill_attrs = params[:skill]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# When rendering a partial, the collection item takes the name
# of the file for the item, so the job object is assigned to
# the local variable `job_form`
job = job_form
job = job_edit
%>
<li>
<form name="edit_job" action="/jobs/edit" method="post" accept-charset="utf-8">
Expand Down
13 changes: 13 additions & 0 deletions views/partials/job_new.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<li>
<form name="new_job" action="/jobs" method="post" accept-charset="utf-8">
<input type="text" name="job[job_title]" placeholder="Job title"> at
<input type="text" name="job[company_name]" placeholder="Company name">
<br>

<label for="job[job_description]">Job Description</label><br>
<textarea name="job[job_description]">Your life story goes here. Keep it concise.</textarea>
<br>

<input type="submit" value="Add job">
</form>
</li>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% skill = skill_form %>
<% skill = skill_edit %>
<li>
<form name="edit_skill" action="/skills/edit" method="post" accept-charset="utf-8" class="mini">
<input type="hidden" name="_method" value="put">
Expand Down
7 changes: 7 additions & 0 deletions views/partials/skill_new.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<li>
<form name="new_skill" action="/skills" method="post" accept-charset="utf-8" class="mini">
<input type="text" name="skill[name]" placeholder="add a skill">

<input type="submit" value="Save">
</form>
</li>
4 changes: 2 additions & 2 deletions views/resumes/edit.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<section class="jobs two_thirds">
<h2>Jobs</h2>
<ul class="no_bullets no_padding">
<%= partial :'partials/job_form', collection: @jobs %>
<%= partial :'partials/job_edit', collection: @jobs %>
</ul>
</section>

<section class="skills one_third">
<h2>Skills</h2>
<ul class="no_bullets no_padding">
<%= partial :'partials/skill_form', collection: @skills %>
<%= partial :'partials/skill_edit', collection: @skills %>
</ul>
</section>
</div>
Expand Down
4 changes: 4 additions & 0 deletions views/resumes/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
<h2>Jobs</h2>
<ul class="no_bullets no_padding">
<%= partial :'partials/job', collection: @jobs %>

<%= partial :'partials/job_new' %>
</ul>
</section>

<section class="skills one_third">
<h2>Skills</h2>
<ul class="no_bullets no_padding">
<%= partial :'partials/skill', collection: @skills %>

<%= partial :'partials/skill_new' %>
</ul>
</section>
</div>
Expand Down