Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage Examples #59

Open
markalanevans opened this issue Feb 23, 2015 · 2 comments
Open

Usage Examples #59

markalanevans opened this issue Feb 23, 2015 · 2 comments

Comments

@markalanevans
Copy link

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?

@ivanoblomov
Copy link
Contributor

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.

@ivanoblomov
Copy link
Contributor

Note that finding by that string does work however:

User.find(User.first.id.hexdigest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants