My code is this

Profile.update_all(["is_active = ?, name = ?, geo_lat = ?, geo_long = ?, radius = ?, search_option = ?", 1, params[:profile_name],'null','null','null','st'])

but it assign

geo_lat=0

and

geo_long=0

In my database structure default value is null for both and i want to assign null please help me

有帮助吗?

解决方案

The issue here are string 'null'.

Try the following:

Profile.update_all(["is_active = ?, name = ?, geo_lat = ?, geo_long = ?, radius = ?, search_option = ?", 1, params[:profile_name], nil, nil, nil, 'st'])

Also check your migration to see if default is not set to string 'null'.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top