Ruby on Rails Thursday, April 26, 2012

I got two models, Book and Word.

class Book < ActiveRecord::Base
has_and_belongs_to_many :words
end

class Word < ActiveRecord::Base
has_and_belongs_to_many :books
end



I got a Join Tables for has_and_belongs_to_many Associations

class CreateBooksWords < ActiveRecord::Migration
def self.up
create_table :books_words, :id => false do |t|
t.integer :book_id
t.integer :word_id

t.timestamps
end
end

def self.down
drop_table :books_words
end
end



Now I want to create Routing, and user can insert words for a book.
How do I do that?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment