Giter Club home page Giter Club logo

admin_script's Introduction

AdminScript

Gem Version Build Status

A module that creates flexible, simple scripts for Rails project.

edit_page_example

Why use AdminScript?

Sometimes we add a button to admin panel to run automated script, but I do not want to design RESTful resource and create new template for such scripts.

AdminScript provides a page of manage these scripts.

All you have to do is adding a script.
No configuration of routing, controller or template.

Getting Started

Add AdminScript to your Gemfile:

gem 'admin_script'

Re-bundle, then run the installer:

$ bundle exec rails generate admin_script:install

AdminScript provides a Rails engine that can display form of AdminScript. Add the following to your config/routes.rb

mount AdminScript::Engine => '/admin_scripts'

Generators

When you have AdminScript installed, you can run...

bundle exec rails generate admin_script:model awesome_script id:integer body:text

...to create the AdminScript::AwesomeScript.

Example

# app/models/admin_script/awesome_script.rb
class AdminScript::AwesomeScript < AdminScript::Base
  # Define attribute name and type
  type_attribute :id, :integer

  def perform
    return false unless valid?

    # do something

    true
  end
end

# app/views/*.html.erb
<%= link_to 'All Scripts', AdminScript.railtie_routes_url_helpers.admin_scripts_path %>
<%= link_to 'Show Form', AdminScript.railtie_routes_url_helpers.admin_script_path(AdminScript::AwesomeScript, admin_script: { id: '1' }) %>
<%= link_to 'Perform Script', AdminScript.railtie_routes_url_helpers.edit_admin_script_path(AdminScript::AwesomeScript, admin_script: { id: '1' }), data: { method: :put } %>

Development

no doc

Links

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alpaca-tc/admin_script.

admin_script's People

Contributors

alpaca-tc avatar

Watchers

James Cloos 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.