[英]Recaptcha::RecaptchaError in Articles#show No site key specified
我明白了:
“文章#中的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
看起来你使用这个gem ,它指定你需要:
export RECAPTCHA_ SITE _KEY ='6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyy'
export RECAPTCHA_ SECRET _KEY ='6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
当我关注你的链接时,你有
export RECAPTCHA_ PUBLIC _KEY = \\'******************************* \\'
export RECAPTCHA_ PRIVATE _KEY = \\'******************************* \\'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.