Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ajaxcrud

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajaxcrud

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

{twitter.com/vikonava}[http://www.twitter.com/vikonava]

= AjaxCRUD

Gem for Rails that creates a convenient scaffold using Ajax in an unobtrusive way usign jQuery and jQueryUI.

This gem has been tested working on Rails 3.

== Requirements

  • jQuery
  • jQuery_ujs
  • jQueryUI (including stylesheet and images)

== Setup

Add the gem to your Gemfile then run +bundle+ to install it.

gem 'ajaxcrud'

Install jQuery and jQueryUI(js and css) using assets on Rails 3.1 by adding the next line to app/assets/javascripts/application.js

app/assets/javascripts/application.js

//= require jquery //= require jquery_ujs //= require jquery-ui

And remember to also add the stylesheet and images included on jQueryUI to the app/assets/stylesheets/ folder.

== Usage

Theres only one command to run the generator and create a scaffold, and goes as follows:

rails g ajaxcrud NAME [field:type:boolean field:type:boolean]

Where NAME is the name of the model you are going to create. Additional to that field is the name of the attribute you are going to add and type is the type of field, just as a regular scaffold. The extra boolean in there is to indicate if that attribute is going to be indexed in the search field, it can be true, false or blank being false as default.

For example, if we are going to create a scaffold for Person which will include attributes name, address, website and phone_number being name and website the only attributes that are going to be indexed in the search field, we should run the following command:

rails g ajaxcrud Person name:string:true address:text website:string:true phone_number:string

This will create the Ajax scaffold and additional to that a general stylesheet to give some default color to the index table, an ajaxcrud helper to make index.html.erb more self-explanatory.

== Additional Configurations

You can configurate the default table to show more attributes that the one's indexed, just edit the show.html.erb file.

== Helpers

Helpers that are going to be added on index.html.erb are:

  • ajaxcrud_js(name, new_text, info_text) post a javascript required code inside your index file. Where name is the name of your model which in our example is person, new_text would be the text to show in the dialog box when a user is going to be created and also info_text works in a similar way but for the show dialog.

  • ajaxcrud_dialogbox(name) is used to post the code that build the dialog boxes on the file. Where name is the name of your model which in our example is person.

  • ajaxcrud_notices(name) is included in the place where notices will be shown in a flash[:notice] style but with some different finish. Where name is the name of your model which in our example is person.

  • ajaxcrud_search(name) is the search field used to look for in the table records. Where name is the name of your model which in our example is person.

  • ajaxcrud_new_link(name) creates the link to enable the New Record dialog. Where name is the name of your model which in our example is person.

  • ajaxcrud_show_link(path) creates the link to render the show.html.erb file of the selected record inside a dialog. Where path is the original way to access the show file.

== Known Bugs

  • When creating the same ajaxcrud twice the migration file is going to be created more than once.
  • If generator destroy is used everything is deleted (including the helper, ajaxcrud.css,...) of the model you indicate EXCEPT the migration file which needs to be removed manually.
  • When destroying a model the ajaxcrud.css and ajaxcrud_helper.rb are also deleted. Since they are being used for all the scaffolds generated you can add them manually and remember to add +include AjaxcrudHelper+ to your app/helpers/application_helper.rb file.

== Special Thanks

This gem was made based on some of the tutorial made by 'Nikunj' at the {Tech Journey}[http://codefundas.blogspot.com/2010/12/create-ajax-based-curd-using-rails-3.html]'s website and being adapted to change or add some functionalities to that.

Also thanks to {Ryan Bates}[http://www.twitter.com/rbates] who helped me find out how to create my first generator and gem, and whose {website}[http://www.railscast.com] is awesome and has helped me a lot learning how to code in Ruby on Rails. Highly Recomended.

FAQs

Package last updated on 22 Oct 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc