Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
郭金龙
@guojinlong
Member
NO. 14322 / 2014-08-01

[email protected]
2 Topics / 6 Replies
0 Followers
0 Following
0 Favorites
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • undefined method `each' for nil:NilClass at September 20, 2014

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

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

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

  • undefined method `each' for nil:NilClass at September 20, 2014

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

  • undefined method `each' for nil:NilClass at September 20, 2014

    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 September 20, 2014

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

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

    报名听讲!

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