Oh, sorry, I didn't understand you completely before. Don't feel stupid; it takes a while to really get the rails way, but then you fly like you've never flow before!
OK, so there are no hard-and-fast rules about where it should go, but definitely in a controller. You could do something like this if you wanted to put it in the MoviesController:
class MoviesController < ApplicationController
# the rest of your movies controller here, then: # this will show a single movie, which is where I am guessing
# you would want to show the actors in that movie and add new actors
def show
@movie = Movie.find(params[:id])
end
# When the user clicks the "add actor" link on the show page
# the will be taken here to fill in actor details
def new_actor
@movie = Movie.find(params[:id])
@actor = @movie.actors.build
end
# When the user clicks the save button on the add actor page
# they will be taken here and eventually back to the show page
def create_actor
@movie = Movie.find(params[:id])
@actor = @movie.actors.build(params[:actor])
if @actor.save
flash[:notice] = "Your actor was successfully added."
redirect_to :action => 'show', :id => @movie.id
else
render :template => "new_actor"
end
end
end
Here are some very basic views:
/* show.html.erb */
<h1><%= @movie.title %></h1>
<ul>
<% @movie.actors.each do |actor| %>
<li><%= actor.name %></li>
<% end %>
</ul>
<%= link_to "add actor", :action => 'new_actor', :id => @movie.id %>/* new_actor.html.erb */
<h1>New Actor for <%= @movie.title %></h1>
<% form_for :actor, @actor, :url => {:action => 'create_actor', :id => @movie.id} do |f| %>
<label for='actor_name'>Name</form><br />
<%= f.text_field :name %>
<%= submit_tag "save" %>
<% end %>
You could do virtually the same thing with a separate ActorsController, just put the new_actor and create_actor actions in that controller, then, anytime you are referencing those actions in other controllers and their views, make sure you specify :controller => :actors along with the :action => ...
Let us know if you have any more questions, there are a ton of very helpful people here just waiting.