Skip to content

Commit

Permalink
product basic validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Mar 7, 2021
1 parent c1cea7f commit f78f741
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/product.rb
@@ -1,2 +1,9 @@
class Product < ApplicationRecord

validates :name, :price, presence: true

def to_s
name
end

end
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Expand Up @@ -11,6 +11,8 @@
</head>

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

0 comments on commit f78f741

Please sign in to comment.