concept Ticket in category ruby

This is an excerpt from Manning's book The Well-Grounded Rubyist, Third Edition.
Let’s define a Ticket class. Inside the class definition, we define a single, simple method:
By defining Ticket.most_expensive, we’ve defined a method that we can access through the class object Ticket but not through its instances. Individual ticket objects (instances of the class Ticket) don’t have this method. You can test this easily. Try adding this to the code from section 3.6.3, where the variable fg referred to a Ticket object (for an event at the fairgrounds):
puts "Testing the response of a ticket instance...." wrong = fg.most_expensive

This is an excerpt from Manning's book Rails 4 in Action: Revised Edition of Rails 3 in Action.
The project resource CRUD was completed in chapter 4, so the next step is to set up the ability to create tickets within the scope of a given project. This chapter explores how to set up a nested resource in Rails, by defining routes for Ticket resources and creating a CRUD interface for them, all scoped under the project resource that you just created.
You need to ensure that when somebody enters a ticket into the application, the title and description attributes are filled in. To do this, define the following validations in the Ticket model.
To implement the code needed to make this scenario pass, add another option to the end of the validation for the description in your Ticket model, like this:
validates :description, presence: true, length: { minimum: 10 }By default, this will generate a message identical to the one you used in your test. You can verify this with the console—if you run rails console and try to create a new Ticket object by using create!, you can get the full text for your error:

This is an excerpt from Manning's book Rails 3 in Action.
With the project resource CRUD done, the next step is to set up the ability to create tickets within the scope of a given project. The term for performing actions for objects within the scope of another object is nesting. This chapter explores how to set up nested routing for Ticket resources by creating a CRUD interface for them, scoped underneath the projects resource that you just created.
You need to ensure that when somebody enters a ticket into the application, the title and description attributes are filled in. To do this, define the following validations inside the Ticket model.
The final line here is written this way because you do not know what the validation message is, but you’ll find out later. To implement this scenario, add another option to the end of the validation for the description in your Ticket model, as shown in the following listing.
Listing 5.7. app/models/ticket.rb
validates :description, :presence => true, :length => { :minimum => 10 }If you go into rails console and try to create a new Ticket object by using create!, you can get the full text for your error: