concept default state in category rails

This is an excerpt from Manning's book Rails 4 in Action: Revised Edition of Rails 3 in Action.
commit d1e9b6f398748d3ca8583727c1f86496465ba298 Author: Rebecca Skinner <[email redacted]> Date: Sat Apr 4 00:00:33 2015 +0800 Protect state_id from users who do not have permission to change it commit ceb67d45cfcddbb8439da7b126802e6a48b1b9ea Author: Rebecca Skinner <[email redacted]> Date: Fri Apr 3 23:27:20 2015 +0800 Only admins and managers can change states of a ticket commit ef5ec0f15e7add662852d6634de50648373f6116 Author: Rebecca Skinner <[email redacted]> Date: Fri Apr 3 23:01:48 2015 +0800 Auto-assign the default state to newly-created tickets
default needs to be a new class method on the State model in order to return the state with the field default set to true. You could have done this query directly in the callback, but that would be exposing the internals of the State model to the Ticket model. The Ticket model doesn’t care that the default value of a State is decided by a Boolean value—it just cares that it can ask the State model what the default state is, and then use it.

This is an excerpt from Manning's book Rails 3 in Action.
If the ticket was assigned the New state, this text would say “State: New ?’ Open,” but because your tickets don’t have default states assigned to them the previous state for the first comment will be nil. When you run this scenario by using bin/cucumber features/creating_comments.feature:33, it will fail:
A default state for the tickets in your application will provide a sensible way of grouping tickets that are new to the system, making it easier for them to be found. The easiest way to track which state is the default state is to add a boolean column called default to your states table, which is set to true if the state is the default, false if not.
git add . git commit -m "Admins can now set a default state for tickets" git push