create_table "tags_pages", :id => false do |t|
t.integer "tag_id", "page_id"
end
add_index "tags_pages", "tag_id"
add_index "tags_pages", "page_id"
How activerecord works on this table ? I want to insert and delete new rows. Sorry if it is a noob question.
Let's suppose you have one page and one tag.
# This will add a "tags_pages" entry, linking one page to one tag
page.tags << tag
# This will delete the appropriate "tags_pages" entry
page.tags.delete(tag)
You can also delete all the tags linked to one page with the clear
method.
page.tags.clear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With