Rjs and partials

having a bit of an issue here with rjs and partials

i have the following controller/action:

class Admin::UsersController < ApplicationController
def new
@user = User.new
@permissions = Permission.find(:all)
@action = “create”
render :update do |page|
page.replace_html(“user_form_message”, “”)
page.replace_html(“user_form”, :partial => “user_form”, :locals =>
{
:user => @user, :permissions => @permissions })
end
end

def edit
@user = User.find(@params[:id])
@permissions = Permission.find(:all)
@action = “update”
render :update do |page|
page.replace_html(“user_form_message”, “”)
page.replace_html(“user_form”, :partial => “user_form”, :locals =>
{
:user => @user, :permissions => @permissions })
end
end
end

and the user_form partial:

<%= form_remote_tag :url => { :controller => “/admin/users”, :action =>
@action } %>
<%= text_field :user, :login, :size => 10, :class => “field”, :onfocus
=> "
this.className=‘field_selected’", :onblur => “this.className=‘field’” %>
<% permissions.each do |perm| -%>
<%= check_box_tag “user[permission_ids][]”, perm.id, @
user.permissions.include?(perm) -%><%= perm.description -%>

<% end -%>
<%= text_field :user, :name, :size => 30, :class => “field”, :onfocus =>
"
this.className=‘field_selected’", :onblur => “this.className=‘field’” %>
<%= submit_tag “Submit”, :class => “button” -%>  
<%= hidden_field :user, :id %>
<%= end_form_tag %>

the problem i am having is that when the new action is rendered, the
form is
displayed empty as it should…but when the edit action is rendered, the
user fields are still blank. it appears that the form fields are
expecting
to have @user accessible. if i remove the :locals from the render call
(and
change the partial to use the instance vars as well), rails complains
that
@permissions is empty, so it appears that the instance vars are not even
available within the partial. is there a way to fix this behavior?

Chris

Are you using the RJS plugin or Edge rails?

On 3/20/06, Chris H. [email protected] wrote:

  page.replace_html("user_form_message", "")
  page.replace_html("user_form_message", "")

<%= text_field :user, :login, :size => 10, :class => “field”, :onfocus =>
<%= hidden_field :user, :id %>

Chris


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Cody F.
http://www.codyfauser.com

plugin.

Chris,

I thought so. I just added the patch from the trunk that fixed that.
Try updating your plugin. You should get Rev 18.

On 3/20/06, Chris H. [email protected] wrote:

i have the following controller/action:
end
end
<% permissions.each do |perm| -%>

available within the partial. is there a way to fix this behavior?


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Cody F.
http://www.codyfauser.com

Cody,

maybe i’m doing something wrong here, so forgive me.

$> script/plugin update javascript_generator_templates
Updating plugin: javascript_generator_templates
svn: ‘javascript_generator_templates’ is not a working copy

i originally installed using the command

script/plugin install javascript_generator_templates

i guess i could do a remove and install again, i just want to make sure
i’m
doing it the correct way.

Chris,

Maybe just nuke the javascript_generator_templates folder and
re-install the plugin using script/plugin install
javascript_generator_templates.

The install must have done an svn export and not an svn checkout.

On 3/20/06, Chris H. [email protected] wrote:

script/plugin install javascript_generator_templates
Try updating your plugin. You should get Rev 18.

having a bit of an issue here with rjs and partials
page.replace_html(“user_form”, :partial => “user_form”, :locals =>
page.replace_html(“user_form_message”, “”)
@action } %>
“this.className=‘field_selected’”, :onblur => " this.className=‘field’"
is
Chris

Rails mailing list



Cody F.
http://www.codyfauser.com

OK, done and done, now have revision 18.

restarted WEBrick and voila, works as expected.

Thanks again!

Chris