Skip to content

ivanmalor/simple_form_ransack

 
 

Repository files navigation

Build Status Code Climate Test Coverage

SimpleFormRansack

SimpleForm and Ransack combined.

Installation

In your Gemfile:

gem 'simple_form_ransack'

In your ApplicationHlper:

module ApplicationHelper
  include SimpleFormRansackHelper
  ...
end

Usage

In your controller:

class CustomerController < ApplicationController
  def index
    @ransack_params = params[:q] || {}
    @ransack = Customer.ransack(@ransack_params)
    @customers = @ransack.result
  end
end

In your views:

<%= simple_search_form_for @ransack, @ransack_params do |f| %>
  <%= f.input :name_cont %>
  <%= f.submit %>
<% end %>

The name_cont input field now gets it label, hint and more translated as normally for a input with name but functions with the input-name q[name_cont], making it much easier to use Ransack and SimpleForm, because you don't have to give label, hint or anything else manually.

About

SimpleForm and Ransack combined.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 83.3%
  • HTML 13.4%
  • JavaScript 1.7%
  • CSS 1.6%