Ferret server

October 23, 2008 at 6:40 am 5 comments

acts_as_ferret gives you a powerful search capability, and it’s much easier to implement than MySQL full text querying.

In development mode,

it’s as simple as adding something like this to your model:

acts_as_ferret :fields => [ :city, :state ]

and this to your controller:

@users = User.find_by_contents(params[:keywords])

But the problem is in the production mode:

I started getting all kinds of corrupted index errors when I put this into production, because acts_as_ferret can’t handle multiple separate processes access the index at once and starting givinng errors as the file not found.

And the answer is also the same and simple:

You have to add :remote => true to your acts_as_ferret declaration,

setup a ferret_server.yaml config file,

If you installed it using script/plugin install, a configuration file stub already has been created in config/ferret_server.yml. In that file you can define the DRb server hostname/ip address and port for each Rails environment (similar to database.yml). Usually you’ll only want this for production mode:

production:
  host: ferret.yourdomain.com
  port: 9009
  pid_file: log/ferret.pid

The pid file path is relative to RAILS_ROOT and is used by the start/stop scripts.

then run:

RAILS_ENV=production script/runner vendor/plugins/acts_as_ferret/script/ferret_server start

in some older versions the command is:

RAILS_ENV=production script/runner “load ‘script/ferret_server'” start
RAILS_ENV=production script/runner “load ‘script/ferret_server'” stop

to start ans stop the server

Entry filed under: RoR. Tags: , , , , , , , , .

File Upload On RoR Apache Configuration For Rails Apps

5 Comments Add your own

  • 1. sandeep campbell  |  October 26, 2008 at 2:01 pm

    Hi Neelmani,

    Thanks for sharing these information, it really helped me in my application. but can u post more article on search engines,
    different search engines and difference.
    Cheers Man,
    Sandeep Campbell

    Reply
  • 2. bond007  |  February 1, 2009 at 4:53 am

    Can you provide the RoR code for a 301 redirect – Moved Permanently?

    Cheers,

    bond007

    Reply
    • 3. neelmani  |  February 18, 2009 at 11:09 am

      hey !
      A 301 redirect code means the requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

      The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

      If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

      Note: When automatically redirecting a POST request after
      receiving a 301 status code, some existing HTTP/1.0 user agents
      will erroneously change it into a GET request.

      301 Redirects are a big part of SEO and making sure that (A) the search engine bots find your content correctly, and (B) understand that the old page or domain is the same as the new one and thus combine the overall rank statistics to the one location. In essence the 301 redirect simply issues a Permanently Moved message in the HTTP header which tells the search engine to only index the target URL.
      the best way is to redirect it from apache config:
      RewriteEngine On
      Redirect 301 /old-dir/old-page.html http://www.domain.com/new-location/new-page.php
      Find out more about mod_rewrite for Apache over at the Apache Module mod_rewrite doc Module mod_rewrite docs.
      http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
      but in rails we can do it by:
      def old_action
      headers[“Status”] = “301 Moved Permanently”
      redirect_to “http://www.new-web-address.com/”
      end

      Reply
  • 4. Monica  |  February 1, 2009 at 4:54 am

    Hi Neelmani… can I invoke render_component outside of the context of a webpage request? My site has a daemon (which I start using script\runner) that sends out email to subscribers every day. To generate said email, I’d like to use the same rendering infrastructure that I use on the normal site. Please advise.

    Reply
    • 5. neelmani  |  February 18, 2009 at 11:02 am

      yes we can for sure render_component from a daemon model. To send mails you can call actionmailer class which uses the normal pages of the site and render them on your emails. Just Use The emailer class to deliver the mails and specify the rhtml view to render on the email page. make sure that your emailer class support the MIME content..

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

October 2008
M T W T F S S
« Sep   Aug »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Most Recent Posts


%d bloggers like this: