README.md in all_futures-1.0.2 vs README.md in all_futures-1.0.3

- old
+ new

@@ -1,9 +1,11 @@ # All Futures -The [all\_futures](https://github.com/leastbad/all_futures) gem offers Rails developers a way to **gather attributes** on an unsaved model **across multiple requests**. It's perfect for [StimulusReflex](https://docs.stimulusreflex.com/) users that are building faceted search interfaces, as well as [Optimism](https://optimism.leastbad.com/) users looking to implement real-time, per-attribute validation schemes. +The [all\_futures](https://github.com/leastbad/all_futures) gem offers Rails developers a way to **gather attributes** on an unsaved model **across multiple requests**. +It's perfect for [StimulusReflex](https://docs.stimulusreflex.com/) users that are building faceted search interfaces, real-time input validation and persisting the display state of low-stakes UI elements. + Try a demo, here: 👉 [Beast Mode StimulusReflex](https://beastmode.leastbad.com/) 👈 [![GitHub stars](https://img.shields.io/github/stars/leastbad/all_futures?style=social)](https://github.com/leastbad/all_futures) [![GitHub forks](https://img.shields.io/github/forks/leastbad/all_futures?style=social)](https://github.com/leastbad/all_futures) [![Twitter follow](https://img.shields.io/twitter/follow/theleastbad?style=social)](https://twitter.com/theleastbad) [![Discord](https://img.shields.io/discord/681373845323513862)](https://discord.gg/GnweR3) ## Why use All Futures? @@ -35,47 +37,47 @@ * Model validations and errors * No need to mess around with temporary records ## How does All Futures work? -First, set up an All Futures class that defines some [attributes](https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute). Your class will inherit from `Possibility`, which is aptly-named. +First, set up an All Futures class that defines some [attributes](https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute). Your class will inherit from `AllFutures`, which is aptly-named: ```ruby -class ExampleModel < Possibility +class ExampleModel < AllFutures attribute :name, :string attribute :age, :integer, default: 21 end ``` Then create an instance and assign it to an instance variable in the controller responsible for your initial page load: ```ruby class ExampleController < ApplicationController def index - @af = ExampleModel.new + @filter = ExampleModel.new end end ``` Emit the instance id as a data attribute on every element which can update your model: ```text -Name: <input type="text" data-af="<%= @af.id %>" data-reflex="input->Example#name" /><br/> -Age: <input type="text" data-af="<%= @af.id %>" data-reflex="input->Example#age" placeholder="<%= @id.age %>" /> +Name: <input type="text" data-filter="<%= @filter.id %>" data-reflex="input->Example#name" /><br/> +Age: <input type="text" data-filter="<%= @filter.id %>" data-reflex="input->Example#age" placeholder="<%= @filter.age %>" /> ``` Since all attributes are gathered and sent to the server during a Reflex operation, it's easy to retrieve the instance id from the Reflex element accessor and use it to call up the correct All Futures object and make changes to it: ```ruby class ExampleReflex < ApplicationReflex def name - model = ExampleModel.find(element.dataset.af) + model = ExampleModel.find(element.dataset.filter) model[:name] = element.value end - + def age - model = ExampleModel.find(element.dataset.af) + model = ExampleModel.find(element.dataset.filter) model[:age] = element.value end end ``` @@ -92,11 +94,11 @@ {% endhint %} All Futures is based on [Active Entity](https://github.com/jasl/activeentity). It is similar to using [ActiveModel::Model](https://api.rubyonrails.org/classes/ActiveModel/Model.html), except that it has full support for [Attributes](https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute), including arrays and nested attributes. All Futures classes behave like ActiveModel classes, so you can inspect `valid?` and the `errors` accessor. ```ruby -class ExampleModel < Possibility +class ExampleModel < AllFutures attribute :name, :string validates :name, presence: true end model = ExampleModel.new @@ -114,12 +116,12 @@ ## Try it now You can experiment with [Beast Mode StimulusReflex](https://beastmode.leastbad.com/), a live demonstration of using All Futures to drill down into a tabular dataset, [**right now**](https://beastmode.leastbad.com/). 👈 -The Beast Mode [codebase](https://github.com/leastbad/beast_mode) [![GitHub stars](https://img.shields.io/github/stars/leastbad/beast_mode?style=social)](https://github.com/leastbad/beast_mode) [![GitHub forks](https://img.shields.io/github/forks/leastbad/beast_mode?style=social)](https://github.com/leastbad/beast_mode) is set up as a template repo which I recommend that you clone and experiment with. +The Beast Mode [codebase](https://github.com/leastbad/beast_mode) [![GitHub stars](https://img.shields.io/github/stars/leastbad/beast_mode?style=social)](https://github.com/leastbad/beast_mode) [![GitHub forks](https://img.shields.io/github/forks/leastbad/beast_mode?style=social)](https://github.com/leastbad/beast_mode) is set up as a **template repo** which I recommend that you clone and experiment with. -The two key files are the [Filter](https://github.com/leastbad/beast_mode/blob/master/app/filters/customer_filter.rb) and the [Reflex](https://github.com/leastbad/beast_mode/blob/master/app/reflexes/customers_reflex.rb). You can read the tutorial post behind this example on my blog [here](https://leastbad.com/beast-mode/). +The three key files are the [Filter](https://github.com/leastbad/beast_mode/blob/master/app/filters/customer_filter.rb), the [Reflex](https://github.com/leastbad/beast_mode/blob/master/app/reflexes/customers_reflex.rb) and the [Model](https://github.com/leastbad/beast_mode/blob/master/app/models/customer.rb). You can read the tutorial post behind this example on my blog [here](https://leastbad.com/beast-mode/). Assuming you're running Ruby 2.7.3, Postgres and have Redis running on your system, you can just run `bin/setup` to install it, including migrations and the DB seed file. {% embed url="https://www.youtube.com/watch?v=Fbo21aWFbhQ" caption="Did they meet at the gym?" %}