-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6822d5f
commit 283a90b
Showing
5 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class PositionsController < ApplicationController | ||
def index | ||
@positions = Position.all | ||
end | ||
|
||
def new | ||
@position = Position.new | ||
end | ||
|
||
def create | ||
# raise.params.inspect | ||
@position = Position.new(position_params) | ||
if @position.save | ||
redirect_to positions_path | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
private | ||
def position_params | ||
params.require(:position).permit(:name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h2>Positions entered to the database: </h2> | ||
|
||
<% @positions.each do |position| %> | ||
<%= position.name %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<hr>positions#new<hr> | ||
|
||
<% if @position.errors.any?%> | ||
<h3><%= pluralize(@position.errors.count, "error") %> occurred: </h3> | ||
<% @position.errors.full_messages.each do |msg| %> | ||
<ul> | ||
<li><%= msg %></li> | ||
</ul> | ||
<% end %> | ||
<% end %> | ||
|
||
<h2>Create a New Position:</h2> | ||
<%= form_for @position do |f| %> | ||
<%= f.label :name %> | ||
<%= f.text_field :name %> | ||
|
||
<%= f.submit %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ | |
resources :positions | ||
end | ||
end | ||
|
||
resources :positions, except: [:show] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters