O'Reilly logo

Learning Sinatra by Manoj Sehrawat, Sudeep Agarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What are the responsibilites of the models?

The application will pass on various requests to the models and hence the models should be ready to handle them. Let's take a look at what each model's responsibilities will be. We will also see what are the corresponding methods that Sequel provides for our ease.

The User model

The User model will be taking care of all the actions possible on a user. The responsibilities will be as follows:

  • It should be able to create a new user.

    We can use the create method on the User model. This create method is defined in Sequel::Model and we can directly use it by passing the required values:

    User.create(name:'user1', password:'password')

    This method will create a user in the users table. If you remember, we have added ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required