ruby on rails - Is there a shortcut for sending AJAX commands? -


So, my app uses a ton of AJAX, and I have to do a lot of things:

  answer_to Format | Format.js render: update | Page | #actual code end end end  

Is there a shortcut?

This controller-built rendering of content is generally considered bad practice because of the MVC architecture of the railways Separation of concerns is broken. This is especially because if so many codes are updated and it happens in many controllers it is getting very difficult to break and maintain quickly.

The shortest route (code-wise) to render, for example, to take advantage of the default view name in its actions like this:

def make @ model = Model New (...) response_to do | Format | End of end of format.js

All that is required to render with a view called "code> create.js.erb . The advantage of using ideas is that, through partly, you can keep the code dry and easy to maintain.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -