无法在PagesController#show中找到带有&id; = id =#39; = // ActiveRecord :: RecordNotFound的页面

时间:2016-07-29 17:43:05

标签: ruby-on-rails ruby activerecord

我在Rails开始一个小项目,一个CMS。我在这里遇到一些问题。

class PagesController< ApplicationController的     布局"管理员"

def index
    @pages = Page.sorted
end

def show
    @page = Page.find(params[:id])
end

def new
    @page = Page.new({:name => "Default"})
    @subjects = Subject.order('position ASC')
    @page_count = Page.count + 1
end

def create
    @page = Page.new(page_params)

    if @page.save
        flash[:notice] = "Page Created Successfully. "
        redirect_to(:action => 'index')
    else
        @subjects = Subject.order('position ASC')
        @page_count = Page.count + 1
        render('new')           
    end 
end

def edit
    @page = Page.find(params[:id])
    @subjects = Subject.order('position ASC')
    @page_count = Page.count
end

def update
    @page = Page.find(params[:id])
    if @page.update_attributes(page_params)
        flash[:notice] = "Page Updated Successfully. "
        redirect_to(:action => 'show')
    else
        @subjects = Subject.order('position ASC')
        @page_count = Page.count 
        render('edit')          
    end
end


def delete
    @page = Page.find(params[:id])
end

def destroy
    page = Page.find(params[:id]).destroy
    flash[:notice] = "Page Destroyed Successfully. "
    redirect_to(:action => 'index')
end

private 
def page_params
    params.require(:page).permit(:subject_id, :name, :permalink, :position, :visible)
end

应用程序错误显示:"无法找到带有&id; =' =" ---" ActiveRecord :: RecordNotFound在PagesController#show"

我无法找到错误,我正在按照教程和我的代码完全按照教程解释...但我仍然不明白为什么会发生这种情况......

手工感谢。

0 个答案:

没有答案