변경할 수없는 데이터베이스에 액세스하고 있으며 attribute
열이 정의되어 있습니다. attribute
에 액세스하려고 시도 할 때마다 예외가 발생합니다.'attribute'라는 열이있는 데이터베이스에서 ActiveRecord를 사용하려면 어떻게해야합니까? (DangerousAttributeError)
? 나는이 문제를 해결하지만,
class << self
def instance_method_already_implemented?(method_name)
return true if method_name == 'attribute'
super
end
end
나를 위해 작동하지에 대한 메일 링리스트 레일에 루비의 계획을 발견
class User < ActiveRecord::Base
def self.authenticate(username,password)
where(:username => username, :value => password).first
end
end
:
내 코드 액티브 (액티브 :: DangerousAttributeError)에 의해 정의된다
중요한지 확실하지 않지만 다음은 내 환경에 대한 세부 정보입니다.
- ruby 1.9.2p0 (2010-08-18 revisi
플랜 A : 29,036) x86_64에-darwin10.4.0] 해결
- 레일
- 3.0.1 액티브 (3.0.1) activeresource (3.0.1)
UPDATE()에 : 열 x
들어
select("username, value").where(:username => username, :value => password).first
'attribute?'또는'attribute'에 대한 예외입니까? 물음표가 어디에 있는지 유의하십시오. –
''attribute? '에 대한 예외.'attribute' 컬럼이 변경되었고 – jean