I have a Reminder model, Attachment Model and it has habtm relationship
with each other.
So I have a created another table as attachment_reminders table in mysql
through migrations and it has reminder_id and attachment_id fields.
In controller I need to copy a record in attachment table and save it in
Attachment table. I am able to do that…
But I need to add the same in the attachment_reminders table also. How
can I achieve it. Please find my code below
def view_reminder @reminder = Reminder.find(params[:id2]) @attachments = @reminder.attachments if request.post? Reminder.create(:sender=>@reminder.user_id,:recipient=>params[:recipient],:body=>params[:body]) @attachments.each do |at| rec = at.clone rec.created_at = Time.now rec.updated_at = Time.now rec.save end flash[:notice]="Reminder updated successfully" redirect_to :controller=>"reminde", :action=>"view_reminder",