In my app users can store private trades in their accounts, such trades are visible only to them.
The Trade model looks like this:
class Trade < ActiveRecord::Base
scope :by_user, lambda { |user|
where(user_id: user.id) unless user.nil?
}
belongs_to :status
belongs_to :user
the route looks like this:
resources :users do
resources :trades
end
so generating urls like:
/users/:user_id/trades/:id/edit
Currently for example, if there are three trades stored in the system, a new user, when creating his first trade would be creating a trade with id = 4, and his URL to find it would be: /users/2/trades/4
I would like to have the trades to have a new sequence_number
column and this to be used in the id to find the trades.
So every user will see only his/her trades, and they will be all numbered starting from 1.