Ruby on Rails, is there a way to copy the contents of table A to table B?

Asked 2 years ago, Updated 2 years ago, 30 views

Hello, everyone I am a student studying Ruby Onrails. As you can see below on the controller, Clear the contents of the code in Restaurant Weight I'd like to copy all the contents of any table to Restaurant Weight.


  3   def my_interest
  4     require 'json'
  5     render json: params
  6     #render text: "jein" 
  7     #redirect_to '/'
  8 
  9     del = RestaurantWeight.all
 10     del.each do |a|
 11       a.destroy
 12     end
 13 
 14   end

ruby ruby-on-rails

2022-09-21 16:26

1 Answers

Delete_all / destroy_all will delete everything.


2022-09-21 16:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.