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

22 篇帖子 / 40 条回帖
0 关注者
0 正在关注
0 收藏
未设置 GitHub 信息。
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • Unpermitted parameters: topic_ids at 2013年10月25日

    #3 楼 @ichord 十分感谢,这样就好了。这是啥道理啊。

  • Unpermitted parameters: topic_ids at 2013年10月25日

    #1 楼 @themorecolor 多谢指点,不过多 save 一次也不致错 我改成这样,就可以了

    def create
      params.permit!
      @place = Place.find(params[:place_id])
      @explaination = @place.explainations.create(params[:explaination].permit(:title, :speaker, :speaker_title, :like))
      @explaination.topic_ids = params[:explaination][:topic_ids]
      @explaination.save
    
      redirect_to @place
    end
    

    我猜测,在 create 那一句,explaination 的 id 还没有确定,无法同时往 explainations_topics 插入记录。必须得先把 explaination 生成了,再往他身上绑 topics。

  • 阿里云上的 rails server 过一会就关闭了 at 2013年09月23日

    得到了这么多素不相识的朋友的热情帮助,十分感激!

    测试了一天,我来总结一下:

    #13 楼 @hsiss #16 楼 @zfjoy520 #17 楼 @kgen #18 楼 @kikyous #19 楼 @cassiuschen 你们是对的,我不知道有「ssh 断掉以后,用户进程就没有了」这件事情,改成后台运行问题就没有了。感谢你们推荐 tmux,这正是我需要的。

    #10 楼 @qhwa #11 楼 @zj0713001 #12 楼 @chaixl #15 楼 @cxh116 感谢你们的分析指导,我检查过你们说的 log,没有有价值的发现。我现在的看法是 512M 内存跑我这个简单的 rails 应用没有问题,可以参考 @lang1pal 对剩余内存的解释。

    @mouse_lin,我的情况和域名没关系,还没绑域名呢

    再次感谢楼上各位!

  • 阿里云上的 rails server 过一会就关闭了 at 2013年09月22日

    #6 楼 @046569 #7 楼 @chaixl 多谢指点!

    我到 /var/log 里去搜 ruby,rails 这些词,也没有啥有意义的发现,用的命令是

    grep -r "rails" *
    

    这样有问题么

  • 阿里云上的 rails server 过一会就关闭了 at 2013年09月22日

    #3 楼 @zj0713001 守着看了会内存,内存也不会随访问有大变化,一直都是剩 100 多 M 的样子,这样有问题么

                 total       used       free     shared    buffers     cached
    Mem:           490        370        119          0         18        206
    -/+ buffers/cache:        144        345
    Swap:            0          0          0
    
  • 阿里云上的 rails server 过一会就关闭了 at 2013年09月22日

    #4 楼 @jimrokliu 我知道这个不应该用在生产环境中。但我是新手,以前没搞过 Server 开发,而且需求也简单,想先让他能用着,以后再来改。

  • 阿里云上的 rails server 过一会就关闭了 at 2013年09月22日

    #1 楼 @jjzxcc log 看过了,并无异常啊,log 的末尾都是正常的,是处理请求的记录。然后,就没有然后了……

  • 嵌套结构的 as_json 只有第一层工作 at 2013年09月22日

    谢谢 @vkill,插件还没来得及看。有一个不用插件的方法是这样的,给每个 Model 都显式写个 as_json_options 方法

    class Place < ActiveRecord::Base
      has_many :guides, :dependent => :destroy
    
      def as_json_options
        @options={}
        @options[:except] ||= [:created_at, :updated_at]
        @options[:include] ||= [:guides => Guide.as_json_options]
        return @options
      end
    
      def as_json(options={})
        super(as_json_options)
      end
    
    end
    
    class Guide < ActiveRecord::Base
      belongs_to :place
      has_many :stories, :dependent => :destroy
    
      def Guide.as_json_options
        options = {}
        options[:except] ||= [:created_at, :updated_at, :keywords]
        options[:include] ||= [:stories => Story.as_json_options]
    
        return options
      end
    
    end
    
  • 集合变 json 不调用元素的 to_json at 2013年09月20日

    谢谢楼上各位 #3 楼 @doitian ,重写 as_json 就对了。

    参考 http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/

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