Hello,
in the last few weeks I`ve taken a clooser look on Ruby and I am
actually impressed on how helpful this “toolset” is.
However, prior to ruby I was mainly working with functional languages
like ASP and PHP for web development.
So my question to you is an archtictural one, as i`m having some
difficulties on how to implement the MVC model correctly:
Let`s say I have a model “Car” and “Part”. A car can have one or more
parts (m:n).
On a specific page the user should be able to change the cars details
and it`s parts (add part, remove part, set quantity etc.).
How would you implement the controllers ?
I would have used the following approach but ran into several problems:
CarsController
–> index
–> show
–> new (needs PartsController/index to display parts)
–> create
–> edit
–> update
PartsController
–> index (displays all parts of a car)
–> show (displays single part of a car)
–> new (add part)
–> create
–> edit (set quantity)
–> update
When I tried to embed the template of “PartsController/index” into the
template “CarsController/new” by using the “render” helper in the
template it doesn`t work.
Example (CarsController/new.html.erb): <%= render @car.pars %> // empty
output
Is this approach the most common way to implement this or I am wrong ?
IF it is correct how do I include another action of another controller
in a view ?
Please be kind, I am a newbie trying the (correct) MVC way…
Thank you very much !