Skip to content
Perform queries through Ransack in Liquid templates
Ruby HTML JavaScript CSS Liquid
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
lib
spec
.gitignore
.rspec
.rubocop.yml
Gemfile
Gemfile.lock
MIT-LICENSE
README.md
Rakefile
liquid_queries.gemspec
shippable.yml

README.md

LiquidQueries

Perform queries on your ActiveRecord collections directly from Liquid templates with the help of Ransack.

Usage

Add a method to a drop that returns a collection:

class MyDrop < Liquid::Drop
  def users
    LiquidQueries::Collection.new(collection: User.all)
  end
end

Then do something like this in your Liquid template:

Kasper's ID is: {{ my_drop.users.ransack.first_name_eq.Kasper.first.id }}
Kasper's last name is {{ my_drop.users.ransack.first_name_eq.Kasper.first.last_name }}

Or something like this:

Users with a name that contains "kasper":

{% for user in my_drop.users.ransack.name_cont.kasper.to_a %}
  {{ user.id }} - {{ user.first_name }} {{ user.last_name }}
{% endfor %}

Installation

Add this line to your application's Gemfile:

gem 'liquid_queries'

And then execute:

$ bundle

Or install it yourself as:

$ gem install liquid_queries

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.