Formatting a list from the DB


#1

I am working on a project where there is a table called mixes. You
create a new Mix and in the contents box, you type in the name of the
songs used. Because the number of tracks could be unlimited, I decided
to use a text box. Is there anyway I can have my views make the list
look right, instead of as a jumble of text. Or, would there be some
way, using arrays and maybe ajax, so the user would see perhaps 10
inputs, and could hit a button and a new field would appear, and this
would go into the db as an array? Thanks!


#2

You can format a bunch of text using RedCloth[1]. For your app,
however, it seems like it’d make a lot more sense to have a Song
model, which belongs_to :mix. A Mix has_many :songs. Yes you can
dynamically add a bunch of songs…take a look at the ajax scaffolding
for some ideas on getting started.

Pat

[1] http://whytheluckystiff.net/ruby/redcloth/


#3

Pat M. wrote:

You can format a bunch of text using RedCloth[1]. For your app,
however, it seems like it’d make a lot more sense to have a Song
model, which belongs_to :mix. A Mix has_many :songs. Yes you can
dynamically add a bunch of songs…take a look at the ajax scaffolding
for some ideas on getting started.

I will look into RedCloth. The reason I want to avoid a model for Song
is because then it is quite probable I would end up with 12 "Eleanor
Rigby"s or something.