activerecord - Remove element from ActiveRecord_Relation in rails -



activerecord - Remove element from ActiveRecord_Relation in rails -

how can remove lastly element activerecord_relation in rails?

e.g. if set:

@drivers = driver.all

i can add together driver object called @new_driver @drivers doing:

@drivers << @new_driver

but how can remove object @drivers?

the delete method doesn't seem work, i.e.

@drivers.delete(0)

you can utilize reject! method, remove object collection without affecting db

for example:

driver_to_delete = @driver.first # need object want removed @drivers.reject!{|driver| driver == driver_to_delete}

ruby-on-rails activerecord

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -