خرید بک لینک

Vote count: 0

I'm new to rails and am struggling to try to find the best solution with models and model associations for a hobby project I am working on. Basically, I want to create a guitar chord generation app that helps a user generate their own guitar chord libraries. A rough demo version is available at https://salty-ridge-10377.herokuapp.com/ if interested.

The flow of the program is for user to generate their desired fretboard and chords that they want to pair with it, and from those fretboard and chord diagrams will be generated. To that end, I created four models: Fretboard, Chord, FretboardDiagram, and ChordDiagram.

I've completed the first step of generating the fretboard. The user enters the name of the fretboard (ex: Standard), the number of strings (ex: 6), the number of frets (24), the tuning as a string in scientific pitch notation ("E2 A2 D3 G3 B3 E4"), and the accidental (# or b), which generates the fretboard (https://salty-ridge-10377.herokuapp.com/fretboards/3)

After that is where things get confusing. I've played with one way to structure the model associations (Fretboard has many Chords has many FretboardDiagrams has many ChordDiagrams), but the nesting is really complex and i've read elsewhere that it is not recommended. Creating the associated views has also been problematic.

Ideally, I would like Fretboard and Chord to have a many to many relationship with each being able to access the fretboard and chord diagrams associated with the pairing:

class Fretboard
  has_and_belongs_to_many :chords
  has_many :fretboard_diagrams
  has_many :chord_diagrams
...
end

class Chord
  has_and_belongs_to_many :fretboards
  has_many :fretboard_diagrams
  has_many :chord_diagrams
...
end

class FretboardDiagram
  belongs_to :chord
  belongs_to :fretboard
...
end

class ChordDiagram
  belongs_to :chord
  belongs_to :fretboard
...
end

I would like to have a view to create a fretboard + chords and then a view to render the associated chord + fretboard diagrams. I would like to have an index of Fretboards displaying associated chords, allowing the user to a select a chord and view the associated chord and fretboard diagrams, and also an index allowing the user to select a Chord and view the associated fretboards, select one of them, and view the associated chord and fretboard diagrams.

Do any of you have suggestions on how this could be accomplished via model associations, controllers, and views? Would it be better to create one controller for all the models to create the desired structure?

Thanks for any help in advance!

.

asked 37 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 5 مرداد 1395 ساعت: 23:10

صفحه بندی