AsyncDataFetch

This project uses MIT-LICENSE.


To use:

In your gemfile

gem 'async_data_fetch'

In application.js

//= require async_data_fetch

In your models:

acts_as_async :METHOD, :METHOD2, ...

You need to explicitely list the methods you want to be available, for security reasons.

In your views, use the helper:

<%= fetch_async(model_name: 'MODEL_NAME', model_id: N , model_method: 'METHOD_NAME', tag: 'TAG', display_error: false, placeholder: 'Loading...', extra_classes: 'class1 class2 ') %>
  • model_name is the name of your model you want to fetch data from

  • model_id is the id of the row

  • model_method is the method you want to call

  • tag is the wrapper tag. Default: ‘span’

  • display_error is for debug, you’ll see more information into the html and into the javascript console. Default: false

  • placeholder is the text which will be there while the data is being fetch. Default: ‘?’

  • extra_classes is to add more classes to the tag. Default: ‘ ’


TODO:

  • make the controller test work. I am having issues with routing if someone wants to help me.

  • make the readme looks better. Sorry for now. If you can help, let me know !