Giter VIP home page Giter VIP logo

leapfrog's Introduction

= Leapfrog

Leapfrog has mainly 2 functions.
One is Migration support. Other is data registration support.

Typically, an enterprise system records the user who submitted the data.
But tables do not have created_by/updated_by columns on scaffold generate.

By you are appending one line into a migration file,  then created_by and
updated_by columns are added.

== Installation

  Download and copy to vender/plugins folder.

  or

  script/plugin install git://kobayashi-tbn.github.com/leapfrog.git

== Example

Migration

  Add 't.users' to Migration file into self.up method.


    class CreateUsers < ActiveRecord::Migration
      def self.up
        create_table :users do |t|
          t.string :name
          t.string :password
          t.string :email

          t.timestamps
          t.users     # add column 'created_by' and 'updated_by'
        end
      end

      def self.down
        drop_table :users
      end
    end


  If you want to add column after created tables,
  Then run script/generate migration add_users_to_todo
  and edit the migration file.(ex. Model name is Todo.)


    class AddUsersToTodo < ActiveRecord::Migration
      def self.up
        add_users :todos
      end

      def self.down
        remove_users :todos
      end
    end


== Controller

ActionController includes Leapfrog::Controller::Users
and each Controller object was extended Leapfrog::Controller::LfMacro
for get the user_id from Leapfrog::UserInfo


== Model

ActiveRecord::Base includes Leapfrog::Model::Observe.
and each Model object was extended Leapfrog::Model::LfMacro
for set data to 'created_by' and 'updated_by' column of the Model.

You need to define 'leapfrog_user_id' in each Model

=== Example

    class Todo < ActiveRecord::Base
      leapfrog_user_id
    end


== How to get the User ID

Leapfrog get user_id from the session in the Controller, so
you have to set the user_id into session[:user_id].


== TODO

I want to be able to use user_name as well as user_id by session[:user_name]


== NOTE

If it is running on development enviroment edit
   config/enviroments/development.rb

    config.cache_classes = true # false(default) -> true



Copyright (c) 2011 Toshinobu Kobayashi, released under the MIT license

leapfrog's People

Contributors

kobayashi-tbn avatar

Stargazers

 avatar

Watchers

 avatar  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.