Forum: Ruby on Rails RE: NOOB: Second post, please help...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B31c8f5031486fa50ec7ee9e1350dec9?d=identicon&s=25 Marcus Blankenship (Guest)
on 2006-05-18 16:43
(Received via mailing list)
Here is my code example:
Fyi - in this example "facility" is the parent table to the "permits"
table.

Page A (facility) links to page B (permits) using this code, and it
works fine.
<%= link_to 'Permits', { :action => '..\permits\list', :facilityid =>
facility}, :post => true %>


Page B (permits) then links back to page A(facility), but this does not
work.
<%= link_to 'Return to facilities', :action => '../facilities/list',
:post => true %>

The error I get when going from page B -> A, is in this code in the
facility/list.rhtml:

	<% for facility in @facilities %>

The message is that @facilities is nil.  "@facilities" gets initialized
by the controller's 'list' property.

Any thoughts?  Should the controller run each time the page is accessed?
Is there a better way to accomplish what I am trying to do?

Thanks,
Marcus
58d6cc890d970ab786d475ed62b460df?d=identicon&s=25 Jeff Everett (Guest)
on 2006-05-18 17:23
(Received via mailing list)
Marcus,

When I try your facilities link_to I get a link like:

http://localhost:3000/facilities/../facilities/lis...

Which does result in @facilities being nil for me.

You might try rewriting the link as

<%= link_to 'Return to facilities', { :controller => 'facilities',
:action
=> 'list' }, :post => true %>

The bit that makes the link url itself in the middle should be enclosed
in
{} so that rails knows where the hash begins and ends. :post is an
option,
not part of the link hash.

HTH

Jeff
This topic is locked and can not be replied to.