我为我的应用编写了一个友好的转发功能,但它在发布请求时失败了。情景如下:
sessions_helper.rb
def store_location
session[:return_to] = request.url
end
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
session.delete(:return_to)
end
application_controller.rb
def require_login
unless !signed_in?
store_location
redirect_to signin_path
end
end
sessions_controller.rb
def create
..
sign_in user
redirect_back_or root_path
..
end
这样可以正常工作,直到你输入POST
个请求。
posts#new
并提交表单 AbstractController::ActionNotFound at /forums/7/posts
The action 'index' could not be found for PostsController
unless action_name = method_for_action(action_name)
raise ActionNotFound, "The action '#{action}' could not be found for #{self.class.name}"
end
知道如何解决这个问题吗?