0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
It's an extraction of the Spree Ecommerce Preferences. All the credits goes to the Spree authors.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0.9.6, ~> 0.9
>= 3.1.0, ~> 3.1
>= 1.3.9, ~> 1.3

Runtime

< 4.2, >= 3.2
< 4.2, >= 3.2
< 4.2, >= 3.2
 Project Readme

PreferĂȘncias

Build Status Gem Version Code Climate Test Coverage

This gem is an extraction of the Spree Ecommerce Open Source Software.

I couldn't find anything as robust as their solution so I decided to extract it into a gem.

Installation

Add this line to your application's Gemfile:

gem 'preferencias'

And then execute:

$ bundle

Or install it yourself as:

$ gem install preferencias

Run migrations

$ rails generate preferencias:migration
$ bundle exec rake db:migrate db:test:prepare

Usage

class YourModel < ActiveRecord::Base
  serialize  :preferences # create a column as text in your database

  preference :color, :string, default: 'red'
  preference :number_of_pokemons, :integer, default: 151
end

@model = YourModel.create(preferences: {number_of_pokemons: 649})
@model.preferred_number_of_pokemons # => 649
@model.preferred_color # => "red"

Contributing

  1. Fork it ( https://github.com/davidslv/preferences/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request