1

This has been asked before, but didn't receive a proper answer:

I have a User that has Files. When a File is updated (via AJAX) I want to refresh the User view.

I do this in RJS:

page['user'].replace_html :partial => 'users/user'

However, the _user.erb.html partial references other partials in the users directory, and e.g. for _name.erb.html Rails complains it can't find the template Files/name. (I want it to look for Users/name).

Is there a way to change the context of the view rendering to that of controller Users? I'd hate to fully-qualify all of the partial rendering requests.

Community
  • 1
  • 1
shmichael
  • 2,985
  • 3
  • 25
  • 32

1 Answers1

0

Maybe try moving the _user.html.erb partial to a 'shared' folder? So the RJS would become:

page['user'].replace_html :partial => 'shared/user'

See http://api.rubyonrails.org/classes/ActionView/Partials.html - a local variable may also need to be defined.

Budgie
  • 2,279
  • 1
  • 21
  • 26
  • Hmmmm, I've just managed to implement something a bit similar in my app and it works fine - I'm guessing you've tried render 'user/name' in your _user partial? – Budgie Aug 05 '10 at 13:37
  • I'm trying to avoid fully-qualifying my partial calls. rendering `user/name` will work, but I don't like the solution. – shmichael Aug 19 '10 at 13:24