Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recaptcha::RecaptchaError in Articles#show No site key specified

I get:

"Recaptcha::RecaptchaError in Articles#show No site key specified."

And I do not understand where is my mistake.

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
like image 356
Boris Avatar asked Jan 01 '26 10:01

Boris


1 Answers

It looks like your using this gem, which specifies that you need:

export RECAPTCHA_SITE_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'

export RECAPTCHA_SECRET_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'

when I follow your link, you have

export RECAPTCHA_PUBLIC_KEY = \'*******************************\'

export RECAPTCHA_PRIVATE_KEY = \'*******************************\'

like image 53
Simple Lime Avatar answered Jan 03 '26 14:01

Simple Lime



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!