我正在NoMethodError
采取new
行动business_controller
。
在我看来,它似乎正在访问@business
表单的对象,然后发生错误:
undefined method `businesses_path' for
这是我的新方法:
def new
if Business.where(:user_id => current_user.id).first.blank?
@business = Business.new
else
redirect_to user_businesses_path(current_user.id)
end
end
我的路线是:
resources :users do
resources :businesses
member do
get 'account'
post 'payment'
put 'update_password'
get 'membership'
end
end
mind.blank 的建议更改
before_filter :check_if_user_has_business, :only => :index
def new
@business = Business.new
end
private
def check_if_user_has_business
redirect_to new_user_business_path(current_user) unless current_user.business
end