librelist archives

« back to archive

finding by id

finding by id

From:
Alan deLevie
Date:
2010-01-25 @ 23:55
I'm making a Sinatra db admin app.

Next to each listing, I have an 'edit' link where href=<%= [object_name].id
%> which gets routed to [object_name]/edit/:id.

An edit form is loaded with an object using
[Object].all(:id => params[:id])

There seems to be something wrong because of the uids. Here's there error:

> Expected "T\342\200\242\305\223
> \303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251" to cast
> to a Friendly::UUID (invalid bytecount)


 So I tried using the added_id as a finder, but got a method missing error.

How can I find a Friendly object by its (uu)id? (or added_id)

Thanks

Re: [friendly] finding by id

From:
James Golick
Date:
2010-01-26 @ 00:12
The trick is to call .to_guid on the UUID when you're trying to put it in a
url (or anywhere else that isn't binary-compatible). That'll cast properly
and look a little nicer.

On Mon, Jan 25, 2010 at 3:55 PM, Alan deLevie <adelevie@gmail.com> wrote:

> I'm making a Sinatra db admin app.
>
> Next to each listing, I have an 'edit' link where href=<%= [object_name].id
> %> which gets routed to [object_name]/edit/:id.
>
> An edit form is loaded with an object using
> [Object].all(:id => params[:id])
>
> There seems to be something wrong because of the uids. Here's there error:
>
>> Expected "T\342\200\242\305\223
>> \303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251" to cast
>> to a Friendly::UUID (invalid bytecount)
>
>
>  So I tried using the added_id as a finder, but got a method missing error
> .
>
> How can I find a Friendly object by its (uu)id? (or added_id)
>
> Thanks
>

Re: [friendly] finding by id

From:
Alan deLevie
Date:
2010-01-26 @ 01:25
Thanks a lot! What does the 'g' in guid stand for?

On Mon, Jan 25, 2010 at 7:12 PM, James Golick <jamesgolick@gmail.com> wrote:

> The trick is to call .to_guid on the UUID when you're trying to put it in a
> url (or anywhere else that isn't binary-compatible). That'll cast properly
> and look a little nicer.
>
>
> On Mon, Jan 25, 2010 at 3:55 PM, Alan deLevie <adelevie@gmail.com> wrote:
>
>> I'm making a Sinatra db admin app.
>>
>> Next to each listing, I have an 'edit' link where href=<%=
>> [object_name].id %> which gets routed to [object_name]/edit/:id.
>>
>> An edit form is loaded with an object using
>> [Object].all(:id => params[:id])
>>
>> There seems to be something wrong because of the uids. Here's there error:
>>
>>> Expected "T\342\200\242\305\223
>>> \303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251" to cast
>>> to a Friendly::UUID (invalid bytecount)
>>
>>
>>  So I tried using the added_id as a finder, but got a method missing erro
>> r.
>>
>> How can I find a Friendly object by its (uu)id? (or added_id)
>>
>> Thanks
>>
>
>

Re: [friendly] finding by id

From:
James Golick
Date:
2010-01-26 @ 01:33
Globally, I guess: http://en.wikipedia.org/wiki/Guid

It's not really a great distinction.

On Mon, Jan 25, 2010 at 5:25 PM, Alan deLevie <adelevie@gmail.com> wrote:

> Thanks a lot! What does the 'g' in guid stand for?
>
>
> On Mon, Jan 25, 2010 at 7:12 PM, James Golick <jamesgolick@gmail.com>wrote:
>
>> The trick is to call .to_guid on the UUID when you're trying to put it in
>> a url (or anywhere else that isn't binary-compatible). That'll cast properly
>> and look a little nicer.
>>
>>
>> On Mon, Jan 25, 2010 at 3:55 PM, Alan deLevie <adelevie@gmail.com> wrote:
>>
>>> I'm making a Sinatra db admin app.
>>>
>>> Next to each listing, I have an 'edit' link where href=<%=
>>> [object_name].id %> which gets routed to [object_name]/edit/:id.
>>>
>>> An edit form is loaded with an object using
>>> [Object].all(:id => params[:id])
>>>
>>> There seems to be something wrong because of the uids. Here's there
>>> error:
>>>
>>>> Expected "T\342\200\242\305\223
>>>> \303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251" to cast
>>>> to a Friendly::UUID (invalid bytecount)
>>>
>>>
>>>  So I tried using the added_id as a finder, but got a method missing err
>>> or.
>>>
>>> How can I find a Friendly object by its (uu)id? (or added_id)
>>>
>>> Thanks
>>>
>>
>>
>

Re: [friendly] finding by id

From:
Alan deLevie
Date:
2010-01-26 @ 01:38
So I convert to_guid to append to a url, the url request is sent, and I have
a string that looks like this in my params hash:
54948ab0-09f6-11df-8a5e-9bf83280a99f

Running Purchase.all(:id => '54948ab0-09f6-11df-8a5e-9bf83280a99f') does not
work.


On Mon, Jan 25, 2010 at 8:33 PM, James Golick <jamesgolick@gmail.com> wrote:

> Globally, I guess: http://en.wikipedia.org/wiki/Guid
>
> It's not really a great distinction.
>
>
> On Mon, Jan 25, 2010 at 5:25 PM, Alan deLevie <adelevie@gmail.com> wrote:
>
>> Thanks a lot! What does the 'g' in guid stand for?
>>
>>
>> On Mon, Jan 25, 2010 at 7:12 PM, James Golick <jamesgolick@gmail.com>wrote:
>>
>>> The trick is to call .to_guid on the UUID when you're trying to put it in
>>> a url (or anywhere else that isn't binary-compatible). That'll cast properly
>>> and look a little nicer.
>>>
>>>
>>> On Mon, Jan 25, 2010 at 3:55 PM, Alan deLevie <adelevie@gmail.com>wrote:
>>>
>>>> I'm making a Sinatra db admin app.
>>>>
>>>> Next to each listing, I have an 'edit' link where href=<%=
>>>> [object_name].id %> which gets routed to [object_name]/edit/:id.
>>>>
>>>> An edit form is loaded with an object using
>>>> [Object].all(:id => params[:id])
>>>>
>>>> There seems to be something wrong because of the uids. Here's there
>>>> error:
>>>>
>>>>> Expected "T\342\200\242\305\223
>>>>> \303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251" to cast
>>>>> to a Friendly::UUID (invalid bytecount)
>>>>
>>>>
>>>>  So I tried using the added_id as a finder, but got a method missing er
>>>> ror.
>>>>
>>>> How can I find a Friendly object by its (uu)id? (or added_id)
>>>>
>>>> Thanks
>>>>
>>>
>>>
>>
>

Re: [friendly] finding by id

From:
choonkeat
Date:
2010-01-26 @ 01:45
Purchase.find('54948ab0-09f6-11df-8a5e-9bf83280a99f') should work

--
choonkeat




On Tue, Jan 26, 2010 at 9:38 AM, Alan deLevie <adelevie@gmail.com> wrote:

> So I convert to_guid to append to a url, the url request is sent, and I
> have a string that looks like this in my params hash:
> 54948ab0-09f6-11df-8a5e-9bf83280a99f
>
> Running Purchase.all(:id => '54948ab0-09f6-11df-8a5e-9bf83280a99f') does
> not work.
>
>
> On Mon, Jan 25, 2010 at 8:33 PM, James Golick <jamesgolick@gmail.com>wrote:
>
>> Globally, I guess: http://en.wikipedia.org/wiki/Guid
>>
>> It's not really a great distinction.
>>
>>
>> On Mon, Jan 25, 2010 at 5:25 PM, Alan deLevie <adelevie@gmail.com> wrote:
>>
>>> Thanks a lot! What does the 'g' in guid stand for?
>>>
>>>
>>> On Mon, Jan 25, 2010 at 7:12 PM, James Golick <jamesgolick@gmail.com>wrote:
>>>
>>>> The trick is to call .to_guid on the UUID when you're trying to put it
>>>> in a url (or anywhere else that isn't binary-compatible). That'll cast
>>>> properly and look a little nicer.
>>>>
>>>>
>>>> On Mon, Jan 25, 2010 at 3:55 PM, Alan deLevie <adelevie@gmail.com>wrote:
>>>>
>>>>> I'm making a Sinatra db admin app.
>>>>>
>>>>> Next to each listing, I have an 'edit' link where href=<%=
>>>>> [object_name].id %> which gets routed to [object_name]/edit/:id.
>>>>>
>>>>> An edit form is loaded with an object using
>>>>> [Object].all(:id => params[:id])
>>>>>
>>>>> There seems to be something wrong because of the uids. Here's there
>>>>> error:
>>>>>
>>>>>> Expected "T\342\200\242\305\223
>>>>>> \303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251" to cast
>>>>>> to a Friendly::UUID (invalid bytecount)
>>>>>
>>>>>
>>>>>  So I tried using the added_id as a finder, but got a method missing e
>>>>> rror.
>>>>>
>>>>> How can I find a Friendly object by its (uu)id? (or added_id)
>>>>>
>>>>> Thanks
>>>>>
>>>>
>>>>
>>>
>>
>

Re: [friendly] finding by id

From:
James Golick
Date:
2010-01-26 @ 02:01
Both should work. Would you gist the error please?

J.

Sent from my iPhone.

On 2010-01-25, at 5:45 PM, choonkeat <choonkeat@gmail.com> wrote:

> Purchase.find('54948ab0-09f6-11df-8a5e-9bf83280a99f') should work
>
> --
> choonkeat
>
>
>
>
> On Tue, Jan 26, 2010 at 9:38 AM, Alan deLevie <adelevie@gmail.com>  
> wrote:
> So I convert to_guid to append to a url, the url request is sent,  
> and I have a string that looks like this in my params hash:  
> 54948ab0-09f6-11df-8a5e-9bf83280a99f
>
> Running Purchase.all(:id => '54948ab0-09f6-11df-8a5e-9bf83280a99f')  
> does not work.
>
>
>
>
>
> On Mon, Jan 25, 2010 at 8:33 PM, James Golick  
> <jamesgolick@gmail.com> wrote:
> Globally, I guess: http://en.wikipedia.org/wiki/Guid
>
> It's not really a great distinction.
>
>
> On Mon, Jan 25, 2010 at 5:25 PM, Alan deLevie <adelevie@gmail.com>  
> wrote:
> Thanks a lot! What does the 'g' in guid stand for?
>
>
> On Mon, Jan 25, 2010 at 7:12 PM, James Golick  
> <jamesgolick@gmail.com> wrote:
> The trick is to call .to_guid on the UUID when you're trying to put  
> it in a url (or anywhere else that isn't binary-compatible). That'll  
> cast properly and look a little nicer.
>
>
> On Mon, Jan 25, 2010 at 3:55 PM, Alan deLevie <adelevie@gmail.com>  
> wrote:
> I'm making a Sinatra db admin app.
>
> Next to each listing, I have an 'edit' link where href=<%=  
> [object_name].id %> which gets routed to [object_name]/edit/:id.
>
> An edit form is loaded with an object using
> [Object].all(:id => params[:id])
>
> There seems to be something wrong because of the uids. Here's there  
> error:
> Expected "T\342\200\242\305\223  
> \303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251"  
> to cast to a Friendly::UUID (invalid bytecount)
>
>  So I tried using the added_id as a finder, but got a method missing  
> error.
>
> How can I find a Friendly object by its (uu)id? (or added_id)
>
> Thanks
>
>
>
>
>

Re: [friendly] finding by id

From:
Alan deLevie
Date:
2010-01-26 @ 02:23
I was running Purchase.all(:id => [guid string]) which doesn't work.
(http://gist.github.com/286477)

Purchase.find([guid string]) does work so I'll just use that.

Thanks.

On Mon, Jan 25, 2010 at 9:01 PM, James Golick <jamesgolick@gmail.com> wrote:
> Both should work. Would you gist the error please?
>
> J.
> Sent from my iPhone.
> On 2010-01-25, at 5:45 PM, choonkeat <choonkeat@gmail.com> wrote:
>
> Purchase.find('54948ab0-09f6-11df-8a5e-9bf83280a99f') should work
> --
> choonkeat
>
>
>
>
> On Tue, Jan 26, 2010 at 9:38 AM, Alan deLevie <adelevie@gmail.com> wrote:
>>
>> So I convert to_guid to append to a url, the url request is sent, and I
>> have a string that looks like this in my params
>> hash: 54948ab0-09f6-11df-8a5e-9bf83280a99f
>> Running Purchase.all(:id => '54948ab0-09f6-11df-8a5e-9bf83280a99f') does
>> not work.
>>
>>
>> On Mon, Jan 25, 2010 at 8:33 PM, James Golick <jamesgolick@gmail.com>
>> wrote:
>>>
>>> Globally, I guess: http://en.wikipedia.org/wiki/Guid
>>> It's not really a great distinction.
>>>
>>> On Mon, Jan 25, 2010 at 5:25 PM, Alan deLevie <adelevie@gmail.com> wrote:
>>>>
>>>> Thanks a lot! What does the 'g' in guid stand for?
>>>>
>>>> On Mon, Jan 25, 2010 at 7:12 PM, James Golick <jamesgolick@gmail.com>
>>>> wrote:
>>>>>
>>>>> The trick is to call .to_guid on the UUID when you're trying to put it
>>>>> in a url (or anywhere else that isn't binary-compatible). That'll cast
>>>>> properly and look a little nicer.
>>>>>
>>>>> On Mon, Jan 25, 2010 at 3:55 PM, Alan deLevie <adelevie@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> I'm making a Sinatra db admin app.
>>>>>> Next to each listing, I have an 'edit' link where href=<%=
>>>>>> [object_name].id %> which gets routed to [object_name]/edit/:id.
>>>>>> An edit form is loaded with an object using
>>>>>> [Object].all(:id => params[:id])
>>>>>> There seems to be something wrong because of the uids. Here's there
>>>>>> error:
>>>>>>>
>>>>>>> Expected "T\342\200\242\305\223
>>>>>>> 
\303\266\021\303\237\302\201\017\302\265\302\215t\302\274<\302\251" to 
cast
>>>>>>> to a Friendly::UUID (invalid bytecount)
>>>>>>
>>>>>>  So I tried using the added_id as a finder, but got a method missing e
>>>>>> rror.
>>>>>> How can I find a Friendly object by its (uu)id?  (or added_id)
>>>>>> Thanks
>>>>
>>>
>>
>
>