✓ I'm available for hire! Check out my open source work on Github or drop me an email

Douglas F Shearer

Posts Tagged with plugin

There are 7 matching posts.

Acts_As_indexed v0.5.0 Released

My Acts_as_indexed plugin has been updated to version 0.5.0.

New in this version is:

  • Ruby 1.9 and Rails 2.3 compatibility.
  • Index location can now be set. Provides Heroku compatibility.
  • Better errors on bad options.
  • ActiveRecord order argument overrides ranking returned by find_by_index.
  • Various test environment improvements
  • Various Bugfixes

Get it on Github or view the RDoc.

 
 

Rails Plugin: Acts As Follower

Followers are the new friends. Apps such as Twitter and Github have effectively enabled virtual stalking within their apps. So how can you do this easily without wasting time with your own join tables? Acts_As_Follower to the rescue!

Install

./script/plugin install git://github.com/tcocca/acts_as_follower.git

Usage

A service like Twitter would have a user model, which would be both a follower and followable…


  class User < ActiveRecord::Base
    acts_as_follower
    acts_as_followable
  end
  
  # In the console...
  user1.follow(user2)
  
  # Get the users following user2
  user2.followers # => # Array containing user1
  
  # Get the users user1 is following
  user1.following # => Array containing user2
  
  # Check following
  user1.following?(user2) # => true
  user2.following?(user1) # => false
  
  # Stop following
  user1.stop_following(user2)
  

Acts_As_Follower allows heterogeneous follow relationships too, so a user could follow repositories and users, say, in an application like Github.

This plugin saved me a lot of time during the start-up of a recent project, and it hopefully should do the same for you. For more usage examples, see the README.

 
 

GMail SMTP with Ruby on Rails and ActionMailer

Trying to use GMail SMTP (or some other SMTP authenticated with TLS) with ActiveRecord to send email in Ruby on Rails? Up till now this involved requiring smtp_tls.rb in your environment.

Thankfully, Kyle Maxwell has come up with a neater solution.

Install

It’s a plugin, which you can get with this command in your Rails root…

./script/plugin install http://svn.kylemaxwell.com/rails_plugins/action_mailer_optional_tls/trunk/

Due to continued downtime of Kyle’s site please use the following URl:

./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git

Setup

You can turn TLS authentication on and off as you need in your environment with a new key that is added to the smtp config, tls. To use with gmail, the following should be in your environment.rb


ActionMailer::Base.smtp_settings = {
    :tls => true,
    :address => "smtp.gmail.com",
    :port => "587",
    :domain => "YOURDOMAIN",
    :authentication => :plain,
    :user_name => "GOOGLEUSERNAME",
    :password => "GOOGLEPASSWORD"
  }

And that’s it. Enjoy.

 
 

Rails Plugin: Will_Paginate_Search

THIS PLUGIN IS NOW DEPRECATED

The features provided by this plugin are now part of the Acts_as_indexed plugin it originally supported.

This plugin allows my acts_as_indexed indexed search plugin to interoperate with the will_paginate pagination plugin.

Install

Prerequisites

For this to work you’ll need the following two plugins…

Install will_paginate_search

./script/plugin install http://svn.douglasfshearer.com/rails/plugins/will_paginate_search

Setup

Follow through the instructions on setting up acts_as_search in the readme, and give the will_paginate readme a read over too.

Searching With Pagination

First argument is the search query (can be a GET variable or anything else), and after that it takes all the standard will_paginate arguments.

@images = Image.paginate_search 'girl', :page => 1, :per_page => 5

Other Stuff

Problems, Comments, Suggestions?

All of the above are most welcome. dougal.s@gmail.com

Credits

Douglas F Shearer

Donate

If you find this plugin useful, please consider a "donation (Paypal) ":https://www.paypal.com/cgi-bin/webscr?cmd=xclick&business=dougal%2es%40gmail%2ecom&item_name=Douglas%20F%20Shearer&buyer_credit_promo_code=&buyer_credit_product_category=&buyer_credit_shipping_method=&buyer_credit_user_address_change=&page_style=Primary&no_shipping=0&return=http%3a%2f%2fdouglasfshearer%2ecom&cancel_return=http%3a%2f%2fdouglasfshearer%2ecom&no_note=1&cn=I%20am%20donating%20because%2e%2e%2e&tax=0&currencycode=GBP&lc=GB&bn=PP%2dDonationsBF&charset=UTF%2d8 to show your support!

 
 

Acts_As_indexed v0.2.1 Released

My Acts_as_indexed plugin has been updated to version 0.2.1.

New in this version is:

  • Search now accepts all the standard Active Record find options.
 
 

Acts_As_indexed v0.2 Released

My Acts_as_indexed plugin has been updated to version 0.2.0.

New in this version is:

  • Major performance improvements.
  • Segmentation of the index can now be tuned.
 
 

Rails Plugin: Acts_As_Indexed

Version 0.4.4 released 04 February 2008 – Fixed some minor AR bugs

This plugin allows ranked boolean-queried fulltext search to be added to any Rails app with no dependencies and minimal setup.

Install

./script/plugin install git://github.com/dougal/acts_as_indexed.git

If you don’t have git installed, you can download the plugin from the GitHub page and unpack it into the vendor/plugins directory of your rails app.

Setup

Add acts_as_indexed to the top of any models you want to index, along with a list of the fields you wish to be indexed.


class Post < ActiveRecord::Base
  acts_as_indexed :fields => [:title, :body]

   ...
end

Searching

To search, call the find_with_index method on your model to search using the index. The optional ids_only parameter, when set to true, will return only the IDs of any matching records.


    # Returns array of Post objects.
	my_search_results = Post.find_with_index('my search query') # =>  [#<Post:0x314b09c @attributes={"...
	
	# Pass any of the ActiveRecord find options to the search.
	my_search_results = Post.find_with_index('my search query',{:limit => 10}) # return the first 10 matches.
	
	# Returns array of IDs.
	my_search_results = Post.find_with_index('my search query',{},{:ids_only => true}) # =>  [12,19,33...

h4. Boolean Query Options

The following query operators are supported:

  • AND – This is the default option. ‘cat dog’ will find records matching ‘cat’ AND ‘dog’.
  • NOT – ‘cat -dog’ will find records matching ‘cat’ AND NOT ‘dog’
  • INCLUDE – “cat +me” will find records matching “cat” and “me”, even if “me” is smaller than the min_word_size.
  • "" – Quoted terms are matched as phrases. ‘“cat dog”’ will find records matching the whole phrase. Quoted terms can be preceded by the NOT operator. ‘cat -“big dog”’ etc.

Pagination

Pagination is supported via the paginate_search method whose first argument is the search query, followed all the standard will_paginate arguments.


@images = Image.paginate_search 'girl', :page => 1, :per_page => 5

Other Stuff

Full Documentation

You can either build the rdoc by running rake rdoc in the acts_as_indexed directory, or look at the latest version online.

Problems, Comments, Suggestions?

All of the above are most welcome. dougal.s@gmail.com

Credits

Douglas F Shearer

Donate

If you find this plugin useful, please consider a donation to show your support!