View “我该怎么做?”;unscope“;Rails 3中的编辑路径和/或操作?
目前,我正在使用Desive开发一个简单的Rails 3 web应用程序。当用户注册时,将创建一个View “我该怎么做?”;unscope“;Rails 3中的编辑路径和/或操作?,view,controller,ruby-on-rails-3.2,default-scope,url-helper,View,Controller,Ruby On Rails 3.2,Default Scope,Url Helper,目前,我正在使用Desive开发一个简单的Rails 3 web应用程序。当用户注册时,将创建一个帐户。这是账户模式的本质: class Account < ActiveRecord::Base include Authority::UserAbilities # Callbacks after_create do |account| account.create_person account.add_role :owner, account.pers
帐户
。这是账户模式的本质:
class Account < ActiveRecord::Base
include Authority::UserAbilities
# Callbacks
after_create do |account|
account.create_person
account.add_role :owner, account.person
end
has_one :person, dependent: :destroy
end
暂时取消编辑操作范围的最佳方法是什么,我应该在
PeopleController\edit
中执行此操作吗?因此在写了这篇文章之后,我意识到在PeopleController\edit
中使用@person=person.unscoped.find(params[:id])
进行取消编辑效果很好。。。但也许其他人有另一种技术。
class Person < ActiveRecord::Base
belongs_to :account
default_scope where(published: true)
end
ActiveRecord::RecordNotFound in PeopleController#edit
Couldn't find Person with id=126 [WHERE "people"."published" = 't']