Socket
Book a DemoInstallSign in
Socket

dalli_captcha

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dalli_captcha

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

dalli_captcha

DalliCaptcha is a captcha engine base on Dalli for Rails 3.2. It provides simple captcha that can be read by human.

Features

  • DalliCaptcha is easy to setup, easy to use.
  • DalliCaptcha provides simple captcha that can be read by human.
  • You don't have to manage image files because they will be removed by Tempfile.
  • The Captcha will be Expired automatically by setting expired_time.
  • ......

Requirements

  • Ruby = ree
  • Rails > 3.2
  • Dalli > 2.4
  • ImageMagick
  • Memcache

I haven't tried lower version yet.

Getting started

1. Add DalliCaptcha to your gemfile

  gem 'dalli_captcha'
or
  gem 'dalli_captcha',:git =>"git://github.com/javyliu/dalli_captcha.git"

2. Generate initializer

    rails g dalli_captcha:install

It'll generate config/initializers/dalli_captcha.rb, and you can configure all options here.

3. Mount DalliCaptcha::Engine in your router.rb

mount DalliCaptcha::Engine => '/captcha', :as => :captcha

4. Add before_filter to your controller

class PostsController < ApplicationController
    before_filter :generate_captcha_key, :only => [:new, :edit]
    ......
end

4. Add module to your model

class Post < ActiveRecord::Base
    include DalliCaptcha::Model
end

if you set config.active_record.whitelist_attributes = true in config/application.rb, remember to add attr_accessible to your model:

attr_accessible :captcha, :captcha_key

to your model.

5. Use DalliCaptcha in your view

<%= image_tag(captcha_path(:timestamp => Time.now.to_i), :alt => "captcha") %>
<%= f.text_field :captcha %>
<%= f.hidden_field :captcha_key, :value => session[:captcha_key] %>

6. Use DalliCaptcha in your controller

    # Initialize a post
    @post = Post.new(:title => "test")

    # valid with captcha
    @post.valid?

    # save with captcha
    @post.save

    # valid without captcha
    @post.valid_without_captcha?

    # save without captcha
    @post.save_without_captcha

Enjoy it!

Todo list

  • To add a simple site
  • To write tests

History

0.0.1

First Version

Author

  • javy_liu@163.com
  • http://hi.baidu.com/javyquan

License

This project rocks and uses MIT-LICENSE.

FAQs

Package last updated on 13 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.