Sha256: 28801966aa853a0b4f236893586365fe9c09be316ff7b7346b1543e0e192ed59

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

class FlatulentController < ApplicationController
  if ENV['RAILS_ENV'] == 'production'
    require 'flatulent.rb'
  else
    $:.unshift '../lib'
    load '../lib/flatulent.rb'
  end

  def figlet
    render :text => Flatulent.figlet(params), :content_type => 'text/plain'
  end

  def element 
    render :text => Flatulent.element(params)
  end

  def form_tags 
    render :text => Flatulent.form_tags(params)
  end
  alias_method 'captcha', 'form_tags'

  def form 
    if params.has_key? 'flatulent'
      valid =
        begin
          Flatulent.validate! params
          true
        rescue Flatulent::Error
          false
        end
    end

    render :inline => <<-html
      <html><body>
        valid? : #{ valid.inspect } <hr> <hr>
        #{ Flatulent.form }
        <hr> <hr> <a href="./">new</a>
      </body></html>
    html
  end
  alias_method 'index', 'form'
  alias_method 'test', 'form'

  

  def ajax 
    if params.has_key? 'flatulent'
      valid =
        begin
          Flatulent.validate! params
          true
        rescue Flatulent::Error
          false
        end
    end

    render :inline => <<-html
      <html>
        <title>Stank Thang</title>
        <head>
          <%= javascript_include_tag 'prototype' %>
        </head>
        <body>
          captcha'd? : #{ valid } <hr> <hr>
          
          <form action='./' method='post'>
            <%= Flatulent.ajax %>
            <hr>
            <input type='submit' name='submit' value='submit' />
          </form>

          <hr> <a href="./">new</a>
        </body>
      </html>
    html
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flatulent-0.0.4 rails/app/controllers/flatulent_controller.rb