How to use a controller/model in a different view

I am trying to put a random rss feed in the main (application) view. The code works if I surf to /feed/, but if I use the same partial outside of views/feeds/ I get errors about nil objects. It seems that the partial does not automatically use it's controller.

I hope this makes sense.

Partials and views don't belong to a controller in particular (except in the sense that their location on disk implies the controller that normally uses them). Your partial probably depends on the controller having setup some instance variable which you are setting up in your FeedController, but not elsewhere.

Fred

The code works if I surf to /feed/, but if I use the same partial outside of views/feeds/ I get errors about nil objects. It seems that

just pass it the parameter it needs, no? (this will create a local variable, though, just to be a little more precise) -

render :partial => 'feeds/partialname', :locals => { :var => @var }

Unfortunately that does not work. It appears that calling a partial does not initialize.

I have:     @feed = Feed.find_by_handle('handle')     @feed.sync if @feed in my application controller.

in application view:

<%= render :partial => 'feeds/rss', :locals => { :feed => @feed } %>

Still getting a nil error: You have a nil object when you didn't expect it! The error occurred while evaluating nil.url

Extracted source (around line #1):

Feed: <a href="<%= @feed.url -%>"><%= @feed.handle -%></a><br/> Title: <%= @feed.title -%><br/> Description: <%= @feed.description -%><br/>

So it is never initializing feed.

Hi,