0.01
No release in over 3 years
Low commit activity in last 3 years
A module for creating flexible, simple scripts for project in Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.13, ~> 1.13
>= 10.0, ~> 10.0
>= 3.0.0, ~> 3.0
>= 1.3, ~> 1.3

Runtime

>= 5.2, < 7.0.0
 Project Readme

This repo is no longer maintained.

AdminScript

Gem Version Build Status

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

preview

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:string

...to create the AdminScript::AwesomeScript.

Example

# app/models/admin_script/awesome_script.rb
class AdminScript::AwesomeScript < AdminScript::Base
  # Define attribute name and 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

# Compile assets

$ yarn install
$ ./node_modules/.bin/webpack

Links

Contributing

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