activeuuid
activeuuid copied to clipboard
Usage Examples
A common rails action response might look something like this:
def create
@ad = Ad.new(ad_params)
@ad.advertiser_id = current_user.advertiser.id
respond_to do |format|
if @ad.save
format.html { redirect_to @ad, notice: 'Ad was successfully created.' }
format.json { render status: :created, json: { success: true, info: @response[:success], data: @ad }}
else
format.html { render :new }
format.json { render status: :unprocessable_entity, json: { success: false, info: @response[:error], errors: @ad.errors } }
end
end
end
In the successful Create case
format.json { render status: :created, json: { success: true, info: @response[:success], data: @ad
The ad.id is sent back to my API as the hex value for ex: 2B77F7F7B1C84130B875E09DE0693329
What am I missing? I need it to be the UUID format.
Also, when running DB queries like in NaviCat, how do you do queries that lookup or join on these binary values?
I'm seeing the same thing and it's because of https://github.com/jashmenn/activeuuid/blob/master/lib/activeuuid/uuid.rb#L20-L22.
No idea why this was desired though.
Note that finding by that string does work however:
User.find(User.first.id.hexdigest)