Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
@justend
会员
第 6054 位会员 / 2013-03-09

3 篇帖子 / 15 条回帖
0 关注者
0 正在关注
0 收藏
未设置 GitHub 信息。
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 参照官方教材写 blog,格式问题请教 at 2013年04月21日

    #3 楼 @cqcn1991 可以了,多谢:)

  • 参照官方教材写 blog,格式问题请教 at 2013年04月21日

    刚才加上试了一下,还不行,还有可能是什么 问题呢?

    controller 中的 create 这样写的

    
    def create
      @post = current_user.posts.build(params[:post])
    
      respond_to do |format|
        if @post.save
          format.html { redirect_to @post, notice: 'Post was successfully created.' }
          format.json { render json: @post, status: :created, location: @post }
        else
          format.html { render action: "new" }
          format.json { render json: @post.errors, status: :unprocessable_entity }
        end
      end
    end
    

    post/show

    = @post.content.html_safe
    
  • 关于一个表和多个表关联的问题请教,谢谢 at 2013年03月30日

    @guyanbiao ha, 这样就可以了,谢谢了

  • 关于一个表和多个表关联的问题请教,谢谢 at 2013年03月30日

    在网上找到另外一种解决方法,已经可以了

    def create
        @post = Post.find(params[:post_id])
        comment_attr = params[:comment].merge :user_id => current_user.id
        @comment = @post.comments.create(comment_attr)
        redirect_to post_path(@post)
      end
    
    
  • 关于一个表和多个表关联的问题请教,谢谢 at 2013年03月30日

    多谢回复,我试了以下的方式,还是没有效果,不知哪里出了问题,

    def create
      @post = Post.find(params[:post_id])
      @comment = @post.comments.create(params[:comment])
      @comment.user = current_user
      redirect_to post_path(@post)
    end
    
  • 吐槽一下新浪微博的 omniauth…… at 2013年03月30日

    搞死了,现在在集成 twitter 的

  • 这几年,发生了什么? at 2013年03月30日

    ......这个,想多了吧?

  • 大家都几点起床,几点睡觉? at 2013年03月30日

    22:00睡 6:30起

  • 被学生恶搞了 at 2013年03月30日

    如果老伯来学 rails,难道是说变成 xi yang 产业了?

  • 社区新规则 - 新注册的用户 1 周内禁止发帖 at 2013年03月30日

    之前能发的,现在不行了,难道要回十个?

  • 在 Slim 模版文件中怎么写如下的格式内容,谢谢 at 2013年03月22日

    有人能帮忙告诉我我在楼上说的问题吗?谢谢

  • 在 Slim 模版文件中怎么写如下的格式内容,谢谢 at 2013年03月20日
    
    <%= link_to "delete", feed_item, method: :delete,
                                     data: { confirm: "You sure?" },
                                     title: feed_item.content %>
    
    

    写成这样不对,这个怎么写呢,谢谢

    = link_to "delete", feed_item, method: :delete, \
                                     data: { confirm: "You sure?" }, \
                                     title: feed_item.content
    
  • 在 Slim 模版文件中怎么写如下的格式内容,谢谢 at 2013年03月20日

    多谢楼上几位,没想到这么快就得到回复,非常感谢:)

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