2016-01-13 34 views
0

这是我ArticleController值总是相同的,在数据​​库中不同的Rails

def new 
    @article = Article.new 
end 

def create 
    #render plain: params[:article].inspect 
    @article = Article.new(super_params) 
    if @article.save 
    flash[:notice] = "Article has been created" 
    redirect_to article_path(@article) 
    else 
    render 'new' 
    end 
end 

def super_params 
    params.require(:article).permit(:title, :description) 
end 

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

的主要问题是,每当我这样做:文章/ 2或5或6,我得到这是因为第一次创建相同的文章。在数据库记录是好的,我只有这个问题,呈现它。

+0

你可以告诉你的路线? –

回答

0

我知道,我所做的:

find_by 

而不是

find 

索里的麻烦...

相关问题