rails 3 associations error

萝らか妹 提交于 2019-12-02 07:15:35

you need to add *@page.build_author* in the new action of pages controller.

  def new
    @page = Page.new
    @page.build_author
    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @page }
    end
  end

It should be @page.build_author instead of @page.author.build. But the logic of this still doesn't look right to me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!