当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How do you render your views with Ajax in RoR 3.1?

问题描述:

I have a controller with a create action and I want to render the new action when there is and error and to redirect to another controller when the save is succesful.

For the moment, I have this kind of method :

def create

@user = User.new(params[:user])

unless @user.save

render :new

end

end

And I have a app/views/MyController/myAction.js.erb which display a message and do Ajax call to my other controller.

It works but I'm not sure than that's the best way. Have you some suggestion? Do you know an Open Source project which use a lot of Ajax.

网友答案:

Take a look at this article I wrote last week.

http://ror-e.com/posts/20-asset-pipeline-best-practices

you might need to learn how to namespace in JS but once you do your JS will be much better.

分享给朋友:
您可能感兴趣的文章:
随机阅读: