I have a complex form in Ruby on Rails 2.3.5, here’s the structure for it:
Artist
– Name
– Albums
-Songs
– Photos
Each artist can albums and several photos. For each album, there are several songs.
I want to create a 3 step process.
– Create Artist
– Create Album (will have option to create multiple songs)
– Create Photos
I want to set it up in a wizard-like way.
My question is actually pretty general – how would you go about (organizationally speaking) creating forms for the models and controllers for such a project?
Currently, I have a model called Artist, a model called Albums and a model called Photos. Artists has many albums and photos. Under which view would I place the form?
Right now, the way it is looking I go to:
artists/new – create the artist, somehow pass artist id to album,
move to albums as albums/new, keep passing that artist id to photos,
photos/new to create photos and then finish -> back to artists/show.
Ideally, I’d like to have something like artists/new/1 to create the artists
artists/new/2 to create the albums and artists/new/3 to create the photos.
How would I go about doing that? Other than routing the pages to where I want them, is that the correct way of organizing things?
Thank you!
You probably need nested routes. It automatically should handle relations.
So you will have links like
artists/1/albums/new,artists/1/albums/5/songs/newetcSo your scenario could sound like this:
artsists/newredirect_to new_artist_article_url @artist_just_created_and_saved