Commit 1a27fac1 authored by Galen Evilla's avatar Galen Evilla

trial

parent 85c61e55
......@@ -31,6 +31,7 @@ class CandidatesController < ApplicationController
#@users = User.all
if @candidate.save
flash[:success] = 'Candidate was created!'
redirect_to candidate_path(@candidate.id)
else
render "candidates/new.html.erb"
......
......@@ -3,5 +3,5 @@ class Candidate < ApplicationRecord
validates :last_name, presence: true
belongs_to :position
belongs_to :user
#belongs_to :user
end
......@@ -4,5 +4,5 @@ class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :candidates
#has_many :candidates
end
<%= simple_form_for(@candidate) do |f| %>
<%= simple_form_for @candidate do |f| %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.input :slogan %>
<%= f.association :position, as: :select %>
<%= f.association :position %>
<%= f.submit %>
<% end %>
......@@ -11,11 +11,13 @@
<li><%= link_to p.last_name, candidate_path(p.id) %></li>
<% end %>
</ul>
<%= link_to "View all Positions", "/positions/#{c.id}" %>
<%= link_to "View all Candidates under #{c.name}" , "/positions/#{c.id}" %>
<% end %>
<hr>
<%= link_to "View Candidates", candidates_path %>
<br>
<%= link_to "Home", root_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