Ruby on rails 3 新建和编辑控制器操作重定向到主“覆盖现有方法”

Ruby on rails 3 新建和编辑控制器操作重定向到主“覆盖现有方法”,ruby-on-rails-3,redirect,overwrite,Ruby On Rails 3,Redirect,Overwrite,我遇到了一个问题,Rails出于某种原因将new和edit方法重定向到主页,但是index和show方法返回得很好 控制器或路由没有什么特别之处,尽管我将在下面介绍它们 我得到的错误是 Started GET "/recipes/new" for 192.168.5.46 at 2011-11-07 11:40:06 -0800 Processing by RecipesController#new as HTML Creating scope :page. Overwriting exis

我遇到了一个问题,Rails出于某种原因将new和edit方法重定向到主页,但是index和show方法返回得很好

控制器或路由没有什么特别之处,尽管我将在下面介绍它们

我得到的错误是

Started GET "/recipes/new" for 192.168.5.46 at 2011-11-07 11:40:06 -0800 Processing by RecipesController#new as HTML Creating scope :page. Overwriting existing method Recipe.page. SQL (4.0ms) SHOW TABLES Creating scope :page. Overwriting existing method User.page. SQL (3.5ms) SHOW TABLES User Load (1.1ms) SELECT `users`.* FROM `users` WHERE (`users`.`id` = 2) LIMIT 1 CACHE (0.1ms) SELECT `users`.* FROM `users` WHERE (`users`.`id` = 2) LIMIT 1 Creating scope :page. Overwriting existing method RoleUser.page. Creating scope :page. Overwriting existing method Role.page. Role Load (2.5ms) SELECT `roles`.* FROM `roles` INNER JOIN `role_users` ON `roles`.id = `role_users`.role_id WHERE ((`role_users`.user_id = 2)) Completed in 887ms Redirected to http://localhost:3000 我假设问题在于这个“覆盖”位,但我不知道为什么它会尝试这样做,然后重定向到主页

我的食谱控制器是

class RecipesController < ApplicationController load_and_authorize_resource before_filter :require_user respond_to :html, :js def index @recipes = Recipe.find_all_by_author_id(current_user.id) end def show @recipe = Recipe.find(params[:id]) end def new return render :text =< 'new recipe' @recipe = Recipe.new end def create @recipe = Recipe.new(params[:recipe]) @recipe.author_id=current_user.id if @recipe.save flash[:notice] = "Successfully created recipe." redirect_to @recipe else render :action =< 'new' end end end 即使new上的渲染文本没有返回,它也会直接转到重定向

有什么想法可以解释为什么会发生这种情况并提出解决建议吗?

方法中的什么:需要用户?
如果您评论load_和authorize_resource,它是否有效?

当然!谢谢,真不敢相信我没看到。现在我必须弄清楚为什么自动化在那个页面上不起作用。似乎错误是使用cancan进行授权。谢谢