vendredi 21 août 2015

why my controller dont work since changing to postgres on rails 4?

I started developing my site in rails 4 with basically the database that comes with RoR sqlt3 and i want to take my site to production in a digital oceans server but they use postgres.. now I thought this was going to work the same way i have i started it. but now im getting errors

PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type timestamp without time zone LINE 1: SELECT "videos".* FROM "videos" WHERE (created_at ) ORDER B... ^ : SELECT "videos".* FROM "videos" WHERE (created_at ) ORDER BY cached_votes_up DESC, created_at DESC

(Controller)

def index
        @videos = Video.all.order("cached_votes_up DESC, created_at DESC")



        @items = Video.order("cached_votes_up DESC, created_at DESC").where("created_at ", Time.zone.now.beginning_of_day)

        @items_by_day = @items.group_by { |t| t.created_at.beginning_of_day }
        @topvideo = Video.order("cached_votes_up DESC, created_at DESC").where("created_at >= ?", Time.zone.now.beginning_of_day)
    end

(View)

<% @items_by_day.sort.reverse.each do |day, items| %>

            <div class="row">
            <h1><%= day.strftime("%d %B %Y") %></h1>

                <div class="topAd">
    <center>
        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsive -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-1876888588409540"
     data-ad-slot="6100356041"
     data-ad-format="auto"></ins>
        <script>
            (adsbygoogle = window.adsbygoogle || []).push({});
        </script>
    </center>
</div>



            <% for a in items %>

            <div class="videothumb col-xs-12 col-sm-4">


                <div class="" style="
    background-size: 100% 100%;
    height: 240px;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    overflow: hidden;">

                    <%= link_to  a do %>
  <div style="background: rgba(0,0,0, 0); width:100%; height: 85%;z-index:1000; position:absolute; top:0;"></div> 
<% end %>

                    <iframe width="100%" height="100%" src="https://www.youtube.com/embed/<%= a.url %>" frameborder="0" allowfullscreen></iframe>

                    </div>
                <div class="col-xs-12">
                <h3>
                    <%= link_to a.title, a %> </h3>
                </div>
                <div class="col-xs-6">
                <h2><%= a.artist %></h2>

                </div>
                <div class="col-xs-6">

                    <div style="text-align:right">
                        <%= link_to like_video_path(a), method: :put, class: "" do %>
                            <span class="glyphicon glyphicon-chevron-up">
                                <%= a.get_upvotes.size %>
                        <% end %> 
                        <%= link_to dislike_video_path(a), method: :put, class: "" do %>
        <span class="glyphicon glyphicon-chevron-down">
        <%= a.get_downvotes.size %>
      <% end %>

                    </div>
                </div>



            </div>
            <% end %>

            </div>


<% end %>

Aucun commentaire:

Enregistrer un commentaire