I am using Ruby on Rails 3 and for a correct organization of my code I would like to have the whole AJAX code related to an action in a respectively 'action.js.rjs' file.
For example, if I have code in a controller like this:
def action
...
format.js {
# BEGIN code to move in to the 'action.js.rjs' file
responds开发者_运维技巧_to_parent do
...
end
# END code to move in to the 'action.js.rjs' file
}
end
is it possible to move in some way the 'responds_to_parent' statement or its content from the controller in to the 'action.js.rjs' file and make it to work?
SOLVED
This should work:
responds_to_parent do
render :action => 'update.js.rjs'
end
精彩评论