On Wed, Jun 15, 2011 at 8:03 PM, Jatin kumar <[email protected]>wrote:

>
>
> On Wed, Jun 15, 2011 at 7:47 PM, Justin Stanczak <[email protected]>wrote:
>
>> You're saying fetch and update if it exists, or create new if it does not?
>> That is what I'm doing. What I'm saying is when I update a new obj with
>> json, the id does not get set. Is this not what you get?
>>
>>
> I am sorry, didn't read it well.
> Yes, you can't do that. However, a workaround is:
> Delete the previous obj, and create a new one.
>
Even that won't work. Just tried it.
You can't mass-assign protected attributes like id

>
>>> On Wed, Jun 15, 2011 at 7:22 PM, Justin Stanczak <[email protected]>wrote:
>>>
>>>> Having issue updating a model with JSON. I simply *
>>>> "model.attributes=json"*, which does update the attributes but not the
>>>> id, or uuid in this case.
>>>
>>> I want to save or create the record (if it's id exists)
>>>
>>> You are updating the records if an existing record is present or any
>>> other condition.
>>> Create your custom method that checks if there are common ids in the json
>>> you are passing and the ids of the records present.For them, call
>>> obj.update_attributes!.
>>>
>>>> . Seems like this would be documented, but I'm not finding anything. I'm
>>>> using a MOM to pass JSON between apps. Thanks.
>>>>
>>>> --
>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to