Remember ids in forms (with association)

Hi there,

I'm building something and I think I'm not going the Rails way with
something. I have two models: 'seasons' and 'episodes'.

# Season model:
has_many :episodes, :dependent => :destroy

# Episode model:
belongs_to :season

# routes.rb
map.resources :seasons, :has_many => :episodes
map.resources :episodes

Episodes belong to seasons, so when I want to create a new episode, I
use this path: new_season_episode_path(season). I create a new episode
instance like this:

@season = Season.find(params[:season_id])
@episode =

Everything's going fine, untill I want to save the whole thing. The
form redirects to '/episodes' (no ID). But I have to save the
season_id in the episode.

@show = Show.find( season id? )
@episode = @show.episodes.create(params[:episode])

Anyone suggestions on how to save it and not use hidden fields in the
form (or do I have to?)?
I hope this is clear enough.


Someday, I hope to know Rails well enough that answers to questions
like this just roll off the tip of my tongue (or, in this case, the
tips of my fingers as I type on the keyboard). For now, the best
answer I can give you is to reference the web page where I learned how
to use nested routes:

I suspect that you want to use instead of, that everything might save correctly when you
save @season, and that you should not be redirecting to /episodes.
But I am nowhere close to being an expert, so I could be sending you
off in the wrong direction.