Sha256: 05ddd28a1d3477c50364ef7b45dbe7cf4ccede0f53262fc480dd31c8f9f4f6ef

Contents?: true

Size: 1.74 KB

Versions: 9

Compression:

Stored size: 1.74 KB

Contents

Rails Core Extensions
====================

[![Build Status](https://travis-ci.org/sealink/rails_core_extensions.png?branch=master)](https://travis-ci.org/sealink/rails_core_extensions)
[![Coverage Status](https://coveralls.io/repos/sealink/rails_core_extensions/badge.png)](https://coveralls.io/r/sealink/rails_core_extensions)
[![Dependency Status](https://gemnasium.com/sealink/rails_core_extensions.png?travis)](https://gemnasium.com/sealink/rails_core_extensions)
[![Code Climate](https://codeclimate.com/github/sealink/rails_core_extensions.png)](https://codeclimate.com/github/sealink/rails_core_extensions)

# DESCRIPTION

Extends the core rails classes with helpful functions

# INSTALLATION

Add to your Gemfile:
gem 'rails_core_extensions'

This gems contains many extensions including a sort extension:

Sortable

This allows you to sort an entire collection by setting the new position of an item
and all other items will reorganise as needed.

```ruby
app/controllers/types_controller.rb
class TypesController < ActionController::Base
  sortable
end

config/routes.rb

In Rails 4/5:
resources :types do
  collection
    post :sort
  end
end
```

You need to submit a collection of objects named the same as the controller.

e.g. for the above the params should be:

types_body[]=1
types_body[]=3
etc.

Where the value is the id, and the position of submission is the new order, e.g.
In the above, the item of id 3 will be updated to position 2

If you have scoped sorts, e.g. sorts within categories you also need to pass in 2 params:
* scope (e.g. category_id)
* a variable by that name, e.g. category_id

So in the above if you want to upgrade category_id 6, you could submit
scope=category_id&category_id=6

along with type_body[]=7.. for all the types in category 6

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_core_extensions-0.11.0.beta.11 README.md
rails_core_extensions-0.10.0 README.md
rails_core_extensions-0.9.0 README.md
rails_core_extensions-0.8.0 README.md
rails_core_extensions-0.7.1 README.md
rails_core_extensions-0.7.0 README.md
rails_core_extensions-0.6.1 README.md
rails_core_extensions-0.6.0 README.md
rails_core_extensions-0.4.0 README.md