Ruby on Rails Monday, November 28, 2011

On Mon, Nov 28, 2011 at 6:00 PM, Norbert Melzer
<timmelzer@googlemail.com> wrote:
> Am 28.11.2011 17:40, schrieb Sebastian:
>
>> Is there no way I can simply assign imei to phone.id during create?
>> That would make my life easier.
>
> Only when wiping the database and creating the phone-table withoud id,
> then creating the row id by hand as type integer.
>

<snip />

This isn't a live system. I'm developing as we speak.

Right now I'm doing the following in my controller.

73 def create
74 @device = Device.new(params[:device])
75 @device.id = @device.device_id.gsub('-', '').to_i
...

(I dont care that I have two columns which contains the same data.
I've spend way too long time on different solutions already.)

However this fails to work in my update method.

91 def update
92 @device = Device.find(params[:id])
93 @device.id = params[:device][:device_id].gsub('-', '').to_i
...

The resulting error message is:
Couldn't find Device with id=777666

I've tried to @device.save after assigning to id with the same result.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment