Search Results

Search found 1 results on 1 pages for 'user323763'.

Page 1/1 | 1 

  • Is this the correct way to set up has many with multiple associations?

    - by user323763
    I'm trying to set up a new project for a music site. I'm learning ROR and am a bit confused about how to make join models/tables. Does this look right? I have users, playlists, songs, and comments. Users can have multiple playlists. Users can have multiple comments on their profile. Playlists can have multiple songs. Playlists can have comments. Songs can have comments. class CreateTables < ActiveRecord::Migration def self.up create_table :users do |t| t.string :login t.string :email t.string :firstname t.string :lastname t.timestamps end create_table :playlists do |t| t.string :title t.text :description t.timestamps end create_table :songs do |t| t.string :title t.string :artist t.string :album t.integer :duration t.string :image t.string :source t.timestamps end create_table :comments do |t| t.string :title t.text :body t.timestamps end create_table :users_playlists do |t| t.integer :user_id t.integer :playlist_id t.timestamps end create_table :playlists_songs do |t| t.integer :playlist_id t.integer :song_id t.integer :position t.timestamps end create_table :users_comments do |t| t.integer :user_id t.integer :comment_id t.timestamps end create_table :playlists_comments do |t| t.integer :playlist_id t.integer :comment_id t.timestamps end create_table :songs_comments do |t| t.integer :song_id t.integer :comment_id t.timestamps end end def self.down drop_table :playlists drop_table :comments drop_table :songs_comments drop_table :users_comments drop_table :users_playlists drop_table :users drop_table :playlists drop_table :songs drop_table :playlists end end

    Read the article

1