Commit 72ce6b7b authored by Galen Evilla's avatar Galen Evilla

added something

parent 1a27fac1
class Candidate < ApplicationRecord class Candidate < ApplicationRecord
validates :first_name, presence: true, uniqueness: true validates :first_name, presence: true, uniqueness: true
validates :last_name, presence: true validates :last_name, presence: true
validates :slogan, presence: true, uniqueness: true
belongs_to :position belongs_to :position
#belongs_to :user #belongs_to :user
......
<%= simple_form_for @candidate do |f| %> <%= simple_form_for @candidate do |f| %>
<%= f.input :first_name %> <%= f.input :first_name, label: 'First Name: '%>
<%= f.input :last_name %> <%= f.input :last_name, label: 'Last Name: '%>
<%= f.input :slogan %> <%= f.input :slogan, label: 'Slogan: '%>
<%= f.association :position %> <%= f.association :position, label: 'Position: '%>
<%= f.submit %> <%= f.submit %>
<% end %> <% end %>
<h1><%= @candidate.first_name %> <%= @candidate.last_name %></h1> <h1><%= @candidate.first_name %> <%= @candidate.last_name %></h1>
<h3>Position: <%= @candidate.position.name%> </h3>
<h3>Slogan:</h3>
<p>
<%= @candidate.slogan %>
</p>
<hr> <hr>
<%= link_to "Back to Candidates", candidates_path %> <%= link_to "Back to Candidates", candidates_path %>
<%= simple_form_for(@position) do |f| %> <%= simple_form_for(@position) do |f| %>
<%= f.input :name %> <%= f.input :name, label: 'Position Name: ' %>
<%= f.submit %> <%= f.submit %>
<% end %> <% end %>
<h1>Positions</h1> <h1>Positions</h1>
<%= link_to("New Position", new_position_path) %> <%= link_to("Add New Position", new_position_path) %>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<h2>(<%= c.id %>) <%= c.name %></h2> <h2>(<%= c.id %>) <%= c.name %></h2>
<ul> <ul>
<% c.candidates.each do |p| %> <% c.candidates.each do |p| %>
<li><%= link_to p.last_name, candidate_path(p.id) %></li> <li><%= link_to "#{p.first_name} #{p.last_name}" , candidate_path(p.id) %></li>
<% end %> <% end %>
</ul> </ul>
<%= link_to "View all Candidates under #{c.name}" , "/positions/#{c.id}" %> <%= link_to "View all Candidates under #{c.name}" , "/positions/#{c.id}" %>
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
<h2>Candidates:</h2> <h2>Candidates:</h2>
<ul> <ul>
<% @candidates.each do |p| %> <% @candidates.each do |p| %>
<li><%= link_to p.last_name, candidate_path(p.id) %></li> <li><%= link_to "#{p.first_name} #{p.last_name}", candidate_path(p.id) %></li>
<% end %> <% end %>
</ul> </ul>
<%= link_to "Add New Candidate", new_candidate_path %>
<hr> <hr>
<%= link_to "Back to Positions", positions_path %> <%= link_to "Back to Positions", positions_path %>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment