Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
郭金龙
@guojinlong
会员
第 14322 位会员 / 2014-08-01

[email protected]
2 篇帖子 / 6 条回帖
0 关注者
0 正在关注
0 收藏
未设置 GitHub 信息。
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • undefined method `each' for nil:NilClass at 2014年09月20日

    #9 楼 @kayakjiang 哦。明白你说的意思了。谢谢大神!

  • [赠书活动][已截止] 闲话 Ruby +《Ruby 基础教程》赠书 (新增译者签名版) at 2014年09月20日

    可惜我已经买了!很不错的入门书。推荐!!!

  • undefined method `each' for nil:NilClass at 2014年09月20日

    #7 楼 @saiga 你是说首先找不到 index,后来就去找同名 index,就算在 private 中用这个 index 的意思吗?

  • undefined method `each' for nil:NilClass at 2014年09月20日

    class ArticlesController < ApplicationController def new @article = Article.new end

    def create @article = Article.new(article_params)

    if @article.save redirect_to @article else render 'new' end end

    def show @article = Article.find(params[:id]) end

    def edit @article = Article.find(params[:id]) end

    def update @article = Article.find(params[:id])

    if @article.update(article_params) redirect_to @article else render 'edit' end end private def article_params params.require(:article).permit(:title, :text) end

    def index @articles = Article.all end end 问题解决了,因为我把 index 写在了 private 下面了。所以@articles估计是在页面就取不到了。但是 index 这个函数却还能访问,奇怪。。。 谢谢大家!!!

  • undefined method `each' for nil:NilClass at 2014年09月20日

    #1 楼 @michael0015 你是说我的@articles查出来时空的吗?

  • [上海] 七周七语言之 Ruby -2014年8月16日 at 2014年08月01日

    报名听讲!

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