Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
niuniu
@xiaoniuniu
Member
NO. 8541 / 2013-08-06

[email protected]
12 Topics / 125 Replies
1 Followers
2 Following
5 Favorites
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • Likeable 里面 like_count 排序的问题 at September 11, 2013

    #3 楼 @virgil 我安装了呢 我的感觉也是 redis 有问题 不知道问题在哪里?

  • Likeable 里面 like_count 排序的问题 at September 11, 2013

    晕 我们三个又撞在一起了!@Martin91 啊哈哈哈~~~

  • Likeable 里面 like_count 排序的问题 at September 11, 2013

    你好 我也在学怎么用 likeable,但是我的会出现: Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED) 是 redis 有问题?

  • 中文网站字体 at September 08, 2013

    #3 楼 @apprentice 我发现了。。。怎么办?

  • 中文网站字体 at September 08, 2013

    #1 楼 @song940 牛!谢谢啦~~~

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #29 楼 @tailang 看过了。。。我试试看哈

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #28 楼 @tailang 好的 我看看试试看

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #26 楼 @tailang 啊 reset 的后果是啥?我对数据库搞不太懂。。。最怕弄这个了。。我试了一下 comment.user.email 也是错的。。。

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #24 楼 @tailang 变了 这是为什么?

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #22 楼 @tailang 好的 我也觉得奇怪。我在 show.html.erb 中调用 comment.user_id 能正确显示出 user 的 id 号。但是用 comment.user.username 就错了 然后我 check 了 commentable,用 comment.commentable.title 也能正确显示,奇怪啊。。。。

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #20 楼 @tailang 好~我搞了半天刚想放弃。。大牛出现了!感动啊~~~~

    class CommentsController < ApplicationController
      def show
        @product = Product.find(params[:product_id])
        @comments = @product.comments.all
      end
    
      def new
        @comment = Comment.new
      end
    
      def edit
        @comment = Comment.find(params[:id])
      end
    
      def update
        @product = Product.find(params[:product_id])
        @comment = Comment.find(params[:id])
        @comment.update_attributes(params[:comment])
        redirect_to @product
      end
    
      def create
        @comment = commentable_record.comments.create(params[:comment])
        @comment.user = current_user #当前用户
    
        respond_to do |format|
          if @comment.save
            format.html {redirect_to commentable_record, notice: '创建评论成功'}
            format.json {render json: @comment, status: :created, location: commentable_record}
          else
            format.html { render action: :new }
            format.json { render json: @comment.errors, status: :unprocessable_entity }
          end
        end
      end
    
      protected
    
      def commentable_record
        Product.find(params[:product_id])
      end
    end
    
    
    
    
  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #18 楼 @tailang 这个是 user.rb

    class User < ActiveRecord::Base
    
      has_many :comments
      validates :email, :presence => true, :uniqueness => true
    
      # Include default devise modules. Others available are:
      # :token_authenticatable, :confirmable,
      # :lockable, :timeoutable and :omniauthable    :authentication_keys
    
      devise :database_authenticatable, :registerable,
             :recoverable, :rememberable, :trackable,
             :validatable
      attr_accessible :username, :email, :password, :password_confirmation, :remember_me
      attr_accessor :login
      attr_accessible :login
    
      def self.find_first_by_auth_conditions(warden_conditions)
        conditions = warden_conditions.dup
        if login = conditions.delete(:login)
          where(conditions).where(["username = :value OR lower(email) = lower(:value)", { :value => login }]).first
        else
          where(conditions).first
        end
      end
    
    ### This is the correct method you override with the code above
    ### def self.find_for_database_authentication(warden_conditions)
    ### end
    
    end
    
    

    出错是 undefined method `username' for nil:NilClass log 信息

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #16 楼 @tailang 应该是写了,不会这么粗心吧。。。我查一下 晚点回复你~~~

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #13 楼 @tailang 我的 comment belongs_to :commentable 和 user,我觉得如果 comment.user_id 能显示出对应的 id,说明 comment 的时候是有 user 对应的。可是就是不知道为何无法显示 username...我现在没有代码 晚些给你看:)

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #13 楼 @tailang 我是完全学习你的内容的。。。唯一的问题就是在 show.html.erb 的时候,没有办法显示 username

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #11 楼 @tailang hello 你的意思是说 user 必须要验证吗?这个 validates 语句放在哪里啊?我查了我的数据库,username 都在的。

    <% @post.comments.each do |comment| %>
         <%= comment.user_id %><br>
         <%= comment.comment %><br>
     <% end -%>
    

    改成 comment.user_id 的时候会显示 user_id 出来,但是写成 comment.user.username 就失败了。为什么呢。

  • 使用 acts_as_commentable 给 post 添加评论,comment 对应一个 user,如何获得 user 的相关信息信息 at September 04, 2013

    #9 楼 @tailang 请问你的问题最后怎么解决的?我遇到和你一样的问题呢。。。

  • active_admin 对应的 views 文件夹 at August 29, 2013

    #7 楼 @zlx_star 按你教的做了,成功了~~~谢谢指点哦!!!

  • active_admin 对应的 views 文件夹 at August 29, 2013

    #7 楼 @zlx_star 太详细了!好感动啊~~~ 因为是后台处理,其实我对页面风格没啥要求,只要基本的功能就可以。我之前没有客制化的时候,生成的 products/edit 无法上传图片,好奇怪啊.... 你的意思是加入这一段对吗?那我先试试看~~~

    For example:
    
      ActiveAdmin.register Post do
        form :partial => "form"
      end
    Then implement app/views/admin/posts/_form.html.erb:
    
      <%= semantic_form_for [:admin, @post] do |f| %>
        <%= f.inputs :title, :body %>
        <%= f.actions :commit %>
      <% end %>
    
  • active_admin 对应的 views 文件夹 at August 29, 2013

    #5 楼 @zlx_star 恩恩~我只是要修改,我想修改 admin/products/edit 页面里面的内容。我又仔细的看了一遍http://www.activeadmin.info/docs/5-forms.html 还是不太明白呢... 我自己的思路是从 MVC 来的,我想要修改 admin/products/edit 页面里面的内容,就应该改 views 的东西。现在后台是有显示内容的,可是不是我想要的。但是我也找不到 admin 对应 views 下面的哪个文件夹 555

  • active_admin 对应的 views 文件夹 at August 29, 2013

    #3 楼 @zlx_star 谢谢哦~这个我提问之前看过...可是还是有问题,感觉这个解决了我 admin/products 页的问题,可是我还是不知道 admin/products/1/edit 这个页面的源代码是从哪里来得 :( 不好意思啊,新手...实在比较晕,拜托帮忙~~~~

  • active_admin 对应的 views 文件夹 at August 29, 2013

    #1 楼 @zlx_star 比如我是用了 product,就是在 app/admin/下自动生成了 product.rb,以下是我的 product.rb 的代码

    ActiveAdmin.register Product do
      index do
        column :title
        column :price
        column "Created Date", :created_at
        default_actions
      end
    
    
    end
    

    default_actions 自动生成了 edit,delete 等功能,我是点到 edit 之后,不知道这个页对应的是什么 view 代码了。edit 的路径是 http://localhost:3000/admin/products/4/edit 我是想修改 admin 的 produtcts 的 edit 界面:)

  • 购买 wrapbootstrap.com at August 25, 2013

    #6 楼 @yuanchunfa 发现了。。。用不来啊!

  • 我的博客代码放 GitHub 了,新手练习适用 at August 25, 2013

    555 刚想学着看 发现网站已经关了

  • 购买 wrapbootstrap.com at August 25, 2013

    是不是可以这么理解,其实 wrapbootstrap 上买得就是美化了的 bootstrap。具体的功能还是需要自己实现的,到时候可以调用一下 css 而已? 我觉得好晕啊,刚搞懂 MVC,现在又在想怎么弄前台后台。自己觉得前台后台的资料很少,初学菜鸟表示入门好难啊。。。。

  • 购买 wrapbootstrap.com at August 24, 2013

    #1 楼 @Tony612 买好了 觉得很好看 可是不会用!!!!疯了

  • 非常好看的 bootstrap 主题,不知道有谁买过? at August 24, 2013

    #12 楼 @changtimwu 我太喜欢他们的风格了 没回来发现用不来。。。能讨论一下怎么用么

  • 一对多关系图片显示的问题 at August 13, 2013

    #89 楼 @Martin91 不是开源呢。。直接邮件你了~

  • 一对多关系图片显示的问题 at August 13, 2013

    #87 楼 @Martin91 我建立了一个 product 和一个 photo 的数据库(之间关系就是 belong_to 和 has_mang),然后我在 photos.image_url 手动在输了图片的名字比如 001.jpg 然后把 001.jpg 拷贝到 app/asset/images 的文件夹下面。我这样做是不是有问题?哎呀...我晕了

  • 一对多关系图片显示的问题 at August 13, 2013

    #85 楼 @Martin91 那你觉得 https://github.com/GBKS/Wookmark-jQuery/blob/master/example/index.html 这个代码是不是有问题呢?因为我看着觉得图片的路径不一样,每个图片对应的尺寸也不一样。那不是就只能手动输入不能遍历了吗?

  • Prev
  • 1
  • 2
  • 3
  • 4
  • 5
  • Next
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English