This example demonstrates validations of ransack search form.
- download it from github:
mkdir ~ && git clone [email protected]:r72cccp/ransack-errors-example.git && cd ransack-errors-example
- install and run migrations:
bundle
rails db:migrate
- create something companies:
RAILS_ENV=development bundle exec rails c
Running via Spring preloader in process 170803
Loading development environment (Rails 6.1.4.4)
2.6.5 :001 > Company.create(name: 'aaa')
2.6.5 :002 > Company.create(name: 'aaabbb')
2.6.5 :003 > Company.create(name: 'ccceeefff')
- run rails server:
rails server
- visit companies page:
http://localhost:3000/companies
The CompanySearchForm validates only length. If searched string is greater than 5 symbols, you must see the error.