开发者

Rails are postgreSQL booleans different from mySQL booleans?

开发者 https://www.devze.com 2023-04-13 00:10 出处:网络
I am using that problem that nothing gets saved on my server that uses PostgreSQL. I have this action here, that updates a boolean it works on my local machine that uses mySQL:

I am using that problem that nothing gets saved on my server that uses PostgreSQL.

I have this action here, that updates a boolean it works on my local machine that uses mySQL:

def reel_online

    @movie = Photographer.find(params[:id])

    if @movie.reel_online == false
      @movie.update_attributes(:reel_online => true)
    else
      @movie.update_attributes(:reel_online => false)
    end

    render :nothing => true
end

The strange thing is that with firebug I can see there is no error on the server, but the boolean dos not get changed.

UPDATE: I changed my action to:

def reel_online

    @movie = Photographer.find(params[:id])

    if @movie.reel_online == 'f'
      @movie.update_attributes(:reel_online => 't')
    else
      @movie.u开发者_高级运维pdate_attributes(:reel_online => 'f')
    end

    render :nothing => true
end

Still there is no error but the boolean is not saved. And my count of true reel_online is 0: <%= @movies.where(:reel_online => 't').count %> In my MySQL database I have set all reel_online to 0


The problem is that in my controller I should use true and false and in view it should be:

<%= @movies.where(:reel_online => 't').count %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号