when a user submits a new item in my app, I want to generate a random
7-digit number for that item. So far, I am a little unclear as to how
this should work.
Here is what I have in my item.rb model
# generate a random item number for each new listing
Now, my question is......
Should I create this random number in my items controller right before
it saves the item to the DB?
# associate user to new item listing
@item = @current_user.items.build(params[:item])
-------------GENERATE RANDOM NUMBER HERE--------------???
flash[:notice] = 'Your item has been successfully submitted!'
flash[:notice] = "Uh Oh! Your item cannot be posted yet."
render :action => "new"
I am thinking that is best method for doing this, but how would I
actually do it? Is this the cleanest way to produce this number?