Skip to content

Commit

Permalink
posts validations and navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
yshmarov committed Mar 11, 2021
1 parent e7a689c commit ebb38db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
class Post < ApplicationRecord

validates :title, :content, presence: true

def to_s
title
end

end
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
</head>

<body>
<br>
<%= link_to "Posts", posts_path %>
<hr>
<%= yield %>
</body>
</html>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
root "posts#index"
resources :posts
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end

0 comments on commit ebb38db

Please sign in to comment.