2013-04-01 3 views
0

last_clicked_on : datetime 속성을 현재 시간으로 업데이트하고 싶습니다.datatime 속성을 업데이트하는 방법은 무엇입니까?

class FeedEntriesController < ApplicationController 
    def show 
    @feed_article = FeedEntry.find(params[:id]) 
    @feed_article.update_attributes(is_to_read: 'false') 
    @feed_article.update_attributes(last_clicked_on: Time.now) 
    @way = @feed_article.url 
    redirect_to @way 
    end 
end 

위의 코드는 작동하지 않습니다. 누군가이 문제를 해결하도록 도와주십시오.

답변

0

나는 당신이 단지이 정보와 함께 당신을 도울 어렵다 어쨌든

@feed_article.is_to_read = 'false' 
@feed_article.last_clicked_on = Time.now 
@feed_article.save! 

을 시도 할 수 있습니다 같아요. 문제는 당신의 열 유형에있을 수 있습니다, 당신은 단지 열 이름 ... 뭔가 다른 ...

PS를 잘못 입력 할 수

DB의 각 update_attributes 문제 트랜잭션, 그래서, 당신은이 거래 대신에이 one ... 위의 코드는 하나의 거래 만 갖습니다.

관련 문제