Im trying to update a ‘default’ field in a model to false, only rows
that belong to a specific user
the idea is to have only one default per user in that table… this is
how im doing it
def default
@neighborhood = UserNeighborhood.find(params[:id])
@neighborhoods = UserNeighborhood.find(:all,:conditions =>
[“user_id = ?”,current_user.id])
@neighborhoods.each do |neighborhood|
neighborhood.default = 0
neighborhood.save!
end
@neighborhood.set_as_default
@neighborhood.save!
redirect_to user_user_neighborhoods_path(current_user)
end
is there a better way?