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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
I'm trying to avoid fully-qualifying my partial calls. rendering user/name will work, but I don't like the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.