Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

refinerycms-pgsearch

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refinerycms-pgsearch

  • 0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Search plugin for RefineryCMS

Github

By: JGW Maxwell

Powered by: pg_search. This only works on PostgreSQL databases, ideally 9.0+.

Installation

Simply use this by adding the following to your Gemfile:

gem 'refinerycms-pgsearch'
# or for the latest and greatest
gem 'refinerycms-pgsearch', github: 'jgwmaxwell/refinerycms-pgsearch'

Then run bundle install, and rails g refinery:search to generate the migrations. Finally, run rake db:migrate and rake db:seed to finish setting up.

# Check The Initializer

The default installation will search in Pages. If you wish to find results in other plugins you have created or installed, you can specify these in config/initializers/refinery/search.rb like so:

Refinery::Search.configure do |config|
    config.searchable_models = {
        "Refinery::Page" => [:title, :all_parts],
        "Refinery::Blog::Post" => [:title, :body]
    }
end

This will index Pages and Blog Posts for you. The format is: "STRING_OF_MODEL_CLASS" => [:array, :of, :attribute, :symbols]. You might notice that Pages are indexing :all_parts - this is a convenience to get the content out of multiple page parts that will be defined if you use it.

# To use your own Models

Simple pass another line into the hash in the initializer, such as:

"Employee" => [:name, :bio]

You can use any public method, as well. So if you have :first_name and :last_name but a method like name to join them, it can be indexed.

# Existing Data and Rebuilding

If at any point you need to rebuild your search index, run rake refinery:search:rebuild to update all your search records!

# Searching and Viewing

A sample search form can be found in views/refinery/shared/_search.html.erb. You can either use this partial directly, or copy the appropriate parts.

If you wish to override the url used in the search results just add a url method to your model and the result of this method will be used instead.

You'll need to run the generator, migrate the database, update the new initializer and remove the old code from application.rb. Then remove the acts_as_indexed statements from your models but otherwise it should be good to go. Let me know if you need help.

FAQs

Package last updated on 21 Jul 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc