2
我有一個使用設計與訂戶模型的rails 3應用程序。我希望訂閱者使用best_in_place gem來更新他們的帳戶信息,但似乎無法得到它來更新數據庫。它將在屏幕上更新,但不是數據庫。Rails 3使用devise和best_in_place gem,不會更新訂戶模型
錯誤發現建議用戶存在是一件壞事,但它不是,因爲如果它不存在就不可能更新該用戶。
我想要做的就是允許用戶從subscriber/accounts#show頁面更新他們的信息,顯示他們的詳細信息。
我的用戶/賬戶控制器具有這樣的:
def update
@subscriber = Subscriber.find(current_subscriber.id)
@subscriber.update_without_password(params[:subscriber])
end
我總是得到這些結果在服務器日誌:
Processing by Subscribers::AccountsController#update as JSON
Parameters: {"subscriber"=>{"firstname"=>"Aarof"}, "authenticity_token"=>"Sx6kEQy4NC56ovikMs/D9nVPGJt1q5jNCoFnNjFhDu8=", "id"=>"2"}
Subscriber Load (1.9ms) SELECT `subscribers`.* FROM `subscribers` WHERE `subscribers`.`id` = 2 LIMIT 1
CACHE (0.0ms) SELECT `subscribers`.* FROM `subscribers` WHERE `subscribers`.`id` = 2 LIMIT 1
(0.2ms) BEGIN
Subscriber Exists (0.4ms) SELECT 1 AS one FROM `subscribers` WHERE (`subscribers`.`email` = BINARY '[email protected]' AND `subscribers`.`id` != 2) LIMIT 1
(0.1ms) ROLLBACK
Redirected to http://localhost:3000/subscribers/accounts/2
Completed 302 Found in 12ms (ActiveRecord: 2.6ms)
我的節目頁面看起來像這樣:
%p.subscriber-account-info
=best_in_place @subscriber, :firstname, :path => subscribers_account_path(@subscriber)
我的訂閱路線如下所示:
subscribers_accounts GET /subscribers/accounts(.:format) subscribers/accounts#index
POST /subscribers/accounts(.:format) subscribers/accounts#create
new_subscribers_account GET /subscribers/accounts/new(.:format) subscribers/accounts#new
edit_subscribers_account GET /subscribers/accounts/:id/edit(.:format) subscribers/accounts#edit
subscribers_account GET /subscribers/accounts/:id(.:format) subscribers/accounts#show
PUT /subscribers/accounts/:id(.:format) subscribers/accounts#update
我剛剛檢查了試圖使用控制檯更新訂戶firstname並收到相同的消息,訂閱者存在,它將事務回滾。這是因爲Devise中的某些事情嗎?
我還沒有嘗試過,說實話,我不知道我需要改變一下。我今晚會看看它。 – 2012-07-30 23:39:22