-
Notifications
You must be signed in to change notification settings - Fork 0
Important points about the construction of the application
Alejandra Rivera edited this page Jun 29, 2022
·
6 revisions
To validate that in the application, when creating a user, an email and a password are required; and when creating a task, a title is requested, I used validates, in the corresponding model.
app/models/user.rb
validates :email, presence: true
validates :password, presence: trueapp/models/item.rb
validates :title, presence: trueTo build the users in the application, I made use of the devise gem. This gem automatically generated the views and documents needed for its implementation.
rails generate devise:views
rails generate devise:installIn the User model, I specified that a user can have many items.
app/models/user.rb
has_many :items In the item model, I specified that the items belong to one user.
app/models/item.rb
belongs_to :userThis allows the application to not display the tasks of a user other than the one logged in.
Ruby on Rails bootcamp project