を指定していない私が手を示しています。reCAPTCHAの::の記事#でRecaptchaErrorはいかなるサイトキーが
"reCAPTCHAのを:: RecaptchaError記事#では、指定なしサイトキーを示していません。"
私は間違いがどこにあるのか分かりません。
Gemfile:
gem 'dotenv-rails', :require => 'dotenv/rails-now'
gem "recaptcha", require: "recaptcha/rails"
.env
export RECAPTCHA_PUBLIC_KEY = '*******************************'
export RECAPTCHA_PRIVATE_KEY = '*******************************'
comments_controller.rb
class CommentsController < ApplicationController
http_basic_authenticate_with name: "admin", password: "**************", only: :destroy
def create
@article = Article.find(params[:article_id])
@comment = @article.comments.create(comment_params)
redirect_to article_path(@article)
end
def destroy
@article = Article.find(params[:article_id])
@comment = @article.comments.find(params[:id])
@comment.destroy
redirect_to article_path(@article)
end
private
def comment_params
params.require(:comment).permit(:commenter, :body)
end
end
articles_controller.rb
class ArticlesController < ApplicationController
http_basic_authenticate_with name: "admin", password: "**********", 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)
end
end
号マイファイル.env:エクスポートRECAPTCHA_PUBLIC_KEY = '******************************' エクスポートRECAPTCHA_PRIVATE_KEY = '**** ********************** ' – Boris
ええ、あなたの.ENVにはRECAPTCHA_PUBLIC_KEYとRECAPTCHA_PRIVATE_KEYがありますが、私がリンクしている宝石を使っていると仮定すると、別のもの、あなたは私たちになる必要がありますRECAPTCHA_SITE_KEYとRECAPTCHA_SECRET_KEYを使用しているため、PUBLICをSITEに変更し、SECRETでPRIVATEを変更すると問題が解決するはずです。 –
大丈夫、解決しました、ありがとうございます。 – Boris