attr-protected

    8熱度

    3回答

    FactoryGirl不會設置我的受保護屬性user.confirmed。這裏最好的做法是什麼? Factory.define :user do |f| f.name "Tim" # attr_accessible -- this works f.confirmed true # attr_protected -- doesn't work end 我可以用我的工廠

    2熱度

    4回答

    我在我的用戶模型下面的代碼: attr_protected :email 我試圖創建一個新的用戶對象,但我得到了下面的代碼質量分配保護錯誤。 user = User.new( :first_name => signup.first_name, :last_name => signup.last_name, :email => signup.email, :

    1熱度

    1回答

    升級到2.0後,許多「黑客」就像訪問受保護的屬性一樣不再可能。 例如(AssetHelper): $scripts = $this->View->_scripts; //pack and return combined scripts 助手致命錯誤,當然。 有誰知道如何在2.0中訪問這些屬性,而不會在這個過程中創建太多開銷? AssetHelper和其他類如果嘗試從Helper中訪問視圖,它

    2熱度

    2回答

    我的用戶模型中有一個字段受保護,因爲它確定了許可級別。所以它應該被保護,而不是可以批量分配的。所以即使屬性在3.2中被默認保護,這實際上是我想要的行爲。 但是,在一個控制器方法中,我希望允許經理分配此字段,例如用戶創建或用戶更新。 如何允許爲特定控制器操作分配該屬性? 例如,我有我的控制器: # app/controllers/admin/users_controller.rb def cre