开发者

Is it possible to move Ruby code from the controller in to a '.js.rjs' file?

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜