Any programmer can answer this in 2 sec, but I'm stumped.

I've just started working with Rails. And I can't figure out what
seems to be the easiest thing imaginable. I need to send
from a view in ferry_controller...

<%= link_to 'Add new schedule', {:controller => 'schedule', :action =>
'new', ferry_id => }%></d>

to a method in schedule_controller...

def new
    @schedule =

and have that value survive into the 'new' view where it will be
returned in[:schedule]).

How is this done? I'm must be utterly simple but I can't figure it


Hey Gavin,

You can create an instance variable the same as you do with the schedule.
@ferry_id = params[:ferry_id]

If the ferry_id is part of the schedule, then you might want to create
the Schedule object with the ferry id
@schedule = :ferry_id => params[:ferry_id]

In either case you'll need a hidden tag on the new page, so the param
gets passed into the create action. If you do things the second way
you just do
<%= f.hidden_field :ferry_id %>

and it'll be slurped up in params[:schedule]


Hey Pat

Thanks for the quick reply. I'm still not sure how the @ferry_id
travels from my ferry_controller's view to the schedule_controller.
Is it something like this:

<%= link_to 'Add new schedule', {:controller => 'schedule', :action =>
'new', ferry_id => }%>

then this:

def new(*args)
    @schedule = :ferry_id => params[:ferry_id]

Something stills feels awkward about it.


That's precisely it, except you'll use :ferry_id in the link_to call of course.

How does it feel awkward to you?


Hey! It works!

I came from C# and .net and it seems to me that the syntax in Ruby and
Rails is less clear. I've only been at it for a week
though...probably just need more time to let it soak in.

Thanks for the help, Pat.