2017-01-11 2 views
0

を作成します。私はクリップとturbolink5を添加し、このためRailsのエラー: <a href="http://guides.rubyonrails.org/getting_started.html" rel="nofollow noreferrer">Rails5</a></p> <p>、フォームにフィールド「添付ファイル」を追加したい:ArticlesController#での例外ArgumentErrorは、私がここからon Railsのチュートリアルを持っている引数の数が間違って(1 2)

class ArticlesController < ApplicationController 

http_basic_authenticate_with name: "gerrit", password: "Ifb6K54WVs7U", except: [:index, :show] 

def index 
    @articles = Article.all 
end 

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



def new 
    @article = Article.new 
end 

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

def create 
    @article = Article.new(article_params) 

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

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

    if @article.update(article_params) 
    redirect_to @article 
    else 
    render 'edit' 
    end 
end 

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

    redirect_to articles_path 
end 

private 
    def article_params 
    params.require(:article).permit(:title, :text, :attachment) 
    end 
end 

次のよう articles_controller.rbです。

私はチュートリアルのすべての設定手順を再実行しますが、私はいつもタイトルにエラーが表示されます。

Extracted source (around line #24): 

def create 
    @article = Article.new(article_params) 

    if @article.save 
    redirect_to @article 

私はここが、article_paramsを単一のparamsを使用しないでください! 何か助けに感謝します!

+0

誰ですか?私の質問は、 'article_params'だけがある場合、' @article = Article.new(article_params) 'が引数の** number **を間違って持つことができます。 – Leder

+0

私はpaperclipをv5.1.0に更新しましたが、エラーはなくなりました。ペーパークリップ関連の問題では、イメージ以外のMIMEタイプの検証は機能しません:[link](https://github.com/thoughtbot/paperclip/issues/1771)。 – Leder

答えて

0

としては最後のコメントで述べている:私はV5.1.0するクリップを更新し、エラーが消えていた

関連する問題

 関連する問題