GithubHelp home page GithubHelp logo

ogura / rails-active-form Goto Github PK

View Code? Open in Web Editor NEW

This project forked from realityforge/rails-active-form

1.0 1.0 0.0 80 KB

A rails plugin for model objects that support validations but are not backed by database tables

License: MIT License

rails-active-form's Introduction

active-form plugin for Rails

active-form is a plugin that makes it easy to have model objects that support the ActiveRecord Validations but are not backed by database tables. The plugin is designed to make it possible to use the ActiveForm derived classes in a very similar manner to the ActiveRecord::Base derived objects.

Originally described at;

www.realityforge.org/articles/2005/12/02/validations-for-non-activerecord-model-objects

How To Define An ActiveForm Object

class Search < ActiveForm

attr_accessor :text
validates_length_of :text, :maximum=>30

end

How To Use ActiveForm Object In Controller

class NavigatorController < ApplicationController

def search
  @search = Search.new(params[:search])
  if @search.valid?
    ...do search here...
  end
end

end

How To Use ActiveForm Object In View

<%= start_form_tag(:action => ‘search’) %> <%= error_messages_for(‘search’) %> <%= text_field(‘search’, ‘text’, {“maxlength” => 30}) %> <button type=“submit”>Save</button> <%= end_form_tag %>

Details

License: Released under the MIT license.

Credits

Peter Donald <peter at realityforge dot org>. Dae San Hwang for fix to work with Rails 1.1. Trevor Squires for suggestion to use Reloadable::Subclasses rather than dispatcher hack for Rails 1.1. Tim Lucas for patch to allow bulk addition of attributes. Geoff Schmidt for adding support for Callbacks. Sean Christman for attributes getter. Jack Christensen for attributes setter. Troy Anderson for fixing human_attribute_name for localizations.

rails-active-form's People

Contributors

realityforge avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.