Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么我不能获取所有喜欢帖子的用户?_Ruby On Rails - Fatal编程技术网

Ruby on rails 为什么我不能获取所有喜欢帖子的用户?

Ruby on rails 为什么我不能获取所有喜欢帖子的用户?,ruby-on-rails,Ruby On Rails,为什么会出现这个错误?我确实在users表中有“last_signed_in_at”列 Mysql2::错误:order子句中的未知列“last_signed_in_at” 我的密码是 控制器 @users = @post.likes 查看 <% @users.order("last_signed_in_at DESC").limit(3).each do |user| %> <li> <%= user.profile.nickname %

为什么会出现这个错误?我确实在users表中有“last_signed_in_at”列

Mysql2::错误:order子句中的未知列“last_signed_in_at”

我的密码是

控制器

@users = @post.likes
查看

<% @users.order("last_signed_in_at DESC").limit(3).each do |user| %>
    <li>
        <%= user.profile.nickname %>
        <%= user.last_active_at %>    
    </li>
<% end %>

  • [#<ActsAsVotable::Vote id: 2, votable_id: 4, votable_type: "Post", voter_id: 1, voter_type: "User", vote_flag: true, created_at: "2012-12-22 13:30:37", updated_at: "2013-01-01 18:55:51">, 
     #<ActsAsVotable::Vote id: 7, votable_id: 4, votable_type: "Post", voter_id: 2, voter_type: "User", vote_flag: true, created_at: "2012-12-23 14:47:04", updated_at: "2013-01-02 00:36:48">]
    
    [#,
    #]
    
    您的作用域是ActsAsVotable::Vote,但不知怎的在等待用户:)

    控制器:

    @users = User.where(:id => @post.likes.map(&:voter_id)).order("last_signed_in_at DESC").limit(3)
    
    视图:


    您的作用域是ActsAsVotable::Vote,但不知怎的在等待用户:)

    控制器:

    @users = User.where(:id => @post.likes.map(&:voter_id)).order("last_signed_in_at DESC").limit(3)
    
    视图:

    
    
    你确定吗?它看起来不像是基于错误消息的。如果删除order()子句,它能工作吗?或者你可能混淆了last_signed_in_at和last_active_at吗?@Jason如果我删除它,现在它显示这个错误未定义的方法'profile',有人能帮我吗?@cat你需要提供更多关于数据结构的详细信息,否则我们只能猜测post/user/profile/。。。看起来像,你确定吗?它看起来不像是基于错误消息的。如果删除order()子句,它能工作吗?或者你可能混淆了last_signed_in_at和last_active_at吗?@Jason如果我删除它,现在它显示这个错误未定义的方法'profile',有人能帮我吗?@cat你需要提供更多关于数据结构的详细信息,否则我们只能猜测post/user/profile/。。。看起来像