Topic: RJS partial scope and other controllers

I have a RJS template in which I want to call a partial that belongs to another controller.

I have a partial called _star.rhtml in views/projects/
My RJS is /views/hot/add.rjs

I call the hot/add method via a form_remote_tag in _star.rhtml and want it to update itself.  Here's the code:


<div id="star<%= %>">
  if @project.in_hot_list?(session[:user_id])
    add_or_del = "del"
    imgsrc = "star_on.gif"
    add_or_del = "add"
    imgsrc = "star_off.gif"
<%= form_remote_tag :url => { :controller => "hot", :action => add_or_del } %>
<%= hidden_field 'hot', 'project_id', :value => %>
<%= hidden_field 'hot', 'user_id', :value => session[:user_id] %>
<input type='image' src='<%= '/images/' + imgsrc %>' />
<%= end_form_tag %>

add method in hot controller:
def add
    @hot =[:hot])
    @project_id = params[:hot][:project_id]

page.replace "star#{project_id}", :partial => 'star' #I don't know what to call here

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: RJS partial scope and other controllers

I think it should be

page.replace "star#{project_id}", :partial => 'projects/star'

(You might need an initial '/' as well

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.