<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum]]></title>
	<link rel="self" href="http://railsforum.com/extern.php?action=feed&amp;type=atom"/>
	<updated>2010-02-09T13:54:48Z</updated>
	<generator>PunBB</generator>
	<id>http://railsforum.com/index.php</id>
		<entry>
			<title type="html"><![CDATA[Validation with making sure certain characters are not included]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37148&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hello,<br />I&#039;m validating a field that should not include certain characters, like ; or !, but can include any other UTF-8 characters, like é or Ő.&nbsp; <br />My original idea was this:</p><div class="codebox"><pre><code>validates_format_of :kulcsszo, :with =&gt; /[\,\;\.\!\?\|\\\(\)\/]/</code></pre></div><p>This in fact does the opposite. It checks if the kulcsszo field <strong>does</strong> include the said characters. </p><p>I can&#039;t find a way to negate this, so the validation would pass only if /[\,\;\.\!\?\|\\\(\)\/]/ does not find anything, meaning the kulccszo does not contain any of the said characters. </p><p>Long story short: how do you validate the exclusion of some characters. </p><p>Thanks a lot.</p>]]></summary>
			<author>
				<name><![CDATA[Flo23]]></name>
				<uri>http://railsforum.com/profile.php?id=31732</uri>
			</author>
			<updated>2010-02-09T13:54:48Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37148&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Need RoR help installation on fedora]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37139&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi,everyone,</p><p>It&#039;s my first time posting here,I&#039;m a newbie on rails I need help on my installation for RoR.I worked for a weeks to make the rails installation success but fail.I thought it was not compatible with fedora or something.Then I tried with virtual one,and it work amazing.</p><p>The problem is :<br />I keep getting this error:<br />[root@alifazman bin]# gem install rails<br />/usr/lib/ruby/site_ruby/1.8/rubygems.rb:9:in `require&#039;: no such file to load -- thread (LoadError)<br />&nbsp; &nbsp; from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:9<br />&nbsp; &nbsp; from /usr/bin/gem:8:in `require&#039;<br />&nbsp; &nbsp; from /usr/bin/gem:8</p><br /><p>I just don&#039;t know what happening.After many time I tried to configure it,also by uninstalling it many time.and Install it step by step as instructed by the tutorial on wiki rails.I&#039;m loss.Hope you guys can help me out..</p><p>Thanks in advance..</p>]]></summary>
			<author>
				<name><![CDATA[alifazman]]></name>
				<uri>http://railsforum.com/profile.php?id=33724</uri>
			</author>
			<updated>2010-02-09T13:40:35Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37139&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[multiple controllers and models tutorial?]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37156&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi:</p><p>I am a newbie. I have been playing only using 1 controller and 1 model.. Any examples out there that I can go beyond this...<br />I think an a deeper understanding of MVC is also required. </p><p>Any recommended readings and links????</p><p>Thanks</p>]]></summary>
			<author>
				<name><![CDATA[Flo23]]></name>
				<uri>http://railsforum.com/profile.php?id=32690</uri>
			</author>
			<updated>2010-02-09T13:20:45Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37156&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Modeling different types of products with different attributes]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37159&amp;action=new"/>
			<summary type="html"><![CDATA[<p>I have an app that I&#039;m working on that shows different products that belong to different categories.&nbsp; For sake of example, let&#039;s assume there are products such as &quot;digital cameras&quot;, &quot;mobile phones&quot; or &quot;portable gps&quot;.</p><p>Each of these is a &quot;product&quot; but will obviously have different attributes.&nbsp; I&#039;d like to be able to add a new product (with common attributes like name, description, category, etc).&nbsp; Then based the product&#039;s category, I want to be able to fill in the other attributes as needed for that category.</p><p><strong>Option 1: Use Single Table Inheritance</strong><br />I looked this up on the forum and elsewhere and saw references to Single Table Inheritance as one possible option.&nbsp; But it seems like that might not be the best approach since, over time and with a large number of categories, that would lead to a huge table full of attributes.</p><p><strong>Option 2: Use Multiple Models for Each Type of Product</strong><br />I could also create models for each type of products (Camera, Phone, Book, etc) but I&#039;d like to be able to add new categories/products from within the admin area of the site once it&#039;s live vs. having to dive into the code each time I want to add to the site.</p><p><strong>Questions:</strong><br /></p><ol class="decimal"><li><p>Any idea how to setup something like this in Rails or any other options I should consider?&nbsp; </p></li><li><p>And is there another concept I&#039;m missing that I should read up on besides Single Table Inheritance that would help point me in the right direction?</p></li></ol><p>Thanks</p><p>Kenton</p>]]></summary>
			<author>
				<name><![CDATA[jamesw]]></name>
				<uri>http://railsforum.com/profile.php?id=20201</uri>
			</author>
			<updated>2010-02-09T13:15:16Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37159&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Changing the :path and :url options of has_attached_file in paperclip]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37126&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hello,</p><p>I am using the paperclip plugin to upload images and it works absolutely fine.</p><p>I intend to save my uploaded images to C:\Application_name\public folder. Accordingly, with some study over the i-net, I changed the :path option of has_attached_file to -</p><p>:path =&gt; &quot;C:/Application_name/public/:class/:attachment/:id/:style_:basename.:extension&quot;</p><p>Now, the files are being saved to the desired path. However, I need to understand what should be the corresponding change in the :url option.</p><p>I tried everything - </p><p>:url =&gt; &quot;/:id/:style_:basename.:extension&quot;<br />:url =&gt; &quot;C:/Application_name/public/:class/:attachment/:id/:style_:basename.:extension&quot;<br />:url =&gt; &quot;/public/:class/:attachment/:id/:style_:basename.:extension&quot;</p><p>but none of them work. The image couldn&#039;t be displayed.</p><p>Request, please share any inputs which could help me further to this.</p><p>Thanks in advance.</p><p>love-n-peace,<br />@shaan<br />Aal izz well...:-)</p>]]></summary>
			<author>
				<name><![CDATA[Flo23]]></name>
				<uri>http://railsforum.com/profile.php?id=27244</uri>
			</author>
			<updated>2010-02-09T13:12:37Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37126&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Damn css, can someone throw me a bone]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37129&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Okay I&#039;ve got a nice little table full of inputs with width set to 100% so they nicely fill each cell but i&#039;ve got a bit of an issue. The table is inserted into the html via ajax after this is done i convert the date fields in jquery-ui datepicker fields which adds a button after the input. Because the width is 100% the button gets pushed to the next line which is fugly. </p><p>What can i do so that the input and button fill 100% of their containing cell?</p>]]></summary>
			<author>
				<name><![CDATA[Vi.]]></name>
				<uri>http://railsforum.com/profile.php?id=15921</uri>
			</author>
			<updated>2010-02-09T12:29:10Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37129&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Only need one user...]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37161&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi there</p><p>I have a simple app that only requires one user to login and perform certain admin tasks.</p><p>What is the best way to set this up. I&#039;m used to using acts_as_authenticated and Clearance in various other projects but this seems like overkill here.</p><p>Thanks</p>]]></summary>
			<author>
				<name><![CDATA[rob-twf]]></name>
				<uri>http://railsforum.com/profile.php?id=7642</uri>
			</author>
			<updated>2010-02-09T09:31:05Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37161&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Production app writing to both development and production log !?]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37167&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Wrote a fairly big app for work and after a healthy round of testing and running it live in development mode, i was finally happy with it and flicked it to production. I was just checking the logs to try and solve a sporadic 422 error problem i&#039;ve been seeing when i noticed that the development log had been written to. Luckily i had the foresight to set both dev &amp; production in the database.yml to point to the live db, but this is quite concerning. I could excuse it if it had just been a ruby process that hadn&#039;t died and was still pointing to dev but the machine itself has been cloned since (it&#039;s a vm) which involves a full shutdown. </p><p>Can anyone offer up an explanation or suggest somewhere i can look for answers. I&#039;ve tried an apache restart today and i&#039;ll keep an eye out to see if the dev log gets written to again. It&#039;s running on rails 2.1.1. and passenger 2.0.3 fwiw</p>]]></summary>
			<author>
				<name><![CDATA[happs74]]></name>
				<uri>http://railsforum.com/profile.php?id=15921</uri>
			</author>
			<updated>2010-02-09T08:21:29Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37167&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[What MYSQL GUI is this?]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=16143&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Here is a screenshot<br /><a href="http://farm3.static.flickr.com/2099/2303421879_21428be917_o.png">http://farm3.static.flickr.com/2099/230 &#133; e917_o.png</a></p><p>Its the one they use in the <a href="http://rubyonrails.org/screencasts">Creating a weblog in 15 minutes</a> screencast</p>]]></summary>
			<author>
				<name><![CDATA[wiehann]]></name>
				<uri>http://railsforum.com/profile.php?id=10349</uri>
			</author>
			<updated>2010-02-09T08:10:41Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=16143&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[search for age range from birth date]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=36917&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Searching by an age attribute would be pretty simple:</p><div class="codebox"><pre><code>def minimum_age_conditions
   [&quot;people.age &gt;= ?&quot;, minimum_age] unless minimum_age.blank?
  end

  def maximum_age_conditions
   [&quot;people.age &lt;= ?&quot;, maximum_age] unless maximum_age.blank?
  end</code></pre></div><p>But instead I have person.birthdate and the age is calculated </p><div class="codebox"><pre><code>def age
    return if birthdate.nil?
    today = Date.today
    if (today.month &gt; birthdate.month) or
       (today.month == birthdate.month and today.day &gt;= birthdate.day)
     #birthdate has happened this year
     today.year - birthdate.year
    else
     today.year - birthdate.year - 1
   end
 end</code></pre></div><p>How can I go from person.birthdate to a range of ages from search?</p>]]></summary>
			<author>
				<name><![CDATA[chief]]></name>
				<uri>http://railsforum.com/profile.php?id=27389</uri>
			</author>
			<updated>2010-02-09T07:51:07Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=36917&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Rails Oracle connection error]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37114&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi,</p><p>I just installed Ruby 191 on Windows XP and the following gems ..</p><p>*** LOCAL GEMS ***<br />actionmailer (2.3.5, 2.3.4)<br />actionpack (2.3.5, 2.3.4)<br />activerecord (2.3.5, 2.3.4)<br />activerecord-oracle-adapter (1.0.0.9250)<br />activerecord-oracle_enhanced-adapter (1.2.3)<br />activeresource (2.3.5, 2.3.4)<br />activesupport (2.3.5, 2.3.4, 2.3.3)<br />archive-tar-minitar (0.5.2)<br />arrayfields (4.7.4)<br />capistrano (2.5.14)<br />color (1.4.0)<br />columnize (0.3.1)<br />fastercsv (1.5.1)<br />fattr (2.1.0)<br />gemcutter (0.3.0)<br />highline (1.5.2)<br />hoe (2.5.0)<br />image_science (1.2.1)<br />json (1.2.0)<br />json_pure (1.2.0)<br />linecache (0.43)<br />log4r (1.1.4)<br />main (4.2.0)<br />mechanize (0.9.3)<br />mini_magick (1.2.5)<br />net-scp (1.0.2)<br />net-sftp (2.0.4)<br />net-ssh (2.0.19)<br />net-ssh-gateway (1.0.1)<br />newgem (1.5.2)<br />nokogiri (1.4.1)<br />open4 (1.0.1)<br />pdf-writer (1.1.8)<br />piston (2.0.8)<br />rack (1.0.1)<br />rack-test (0.5.3)<br />rails (2.3.5, 2.3.4)<br />rake (0.8.7)<br />RedCloth (4.2.2)<br />rspec (1.3.0)<br />rubigen (1.5.2)<br />ruby-oci8 (2.0.3)<br />rubyforge (2.0.3)<br />rubygems-update (1.3.5)<br />ruport (1.6.3)<br />sashimi (0.2.2)<br />syntax (1.0.0)<br />transaction-simple (1.4.0)<br />webrat (0.7.0)<br />ZenTest (4.2.1)</p><p>and a test works well ...</p><p>ruby -r oci8 -e &quot;OCI8.new(&#039;scott&#039;, &#039;t&#039;, &#039;CP&#039;).exec(&#039;SELECT * FROM dept ORDER BY 1&#039;) do |r|puts&nbsp; r.join(&#039; | &#039;); end&quot;<br />Warning: NLS_LANG is not set. fallback to US-ASCII.<br />10 | ACCOUNTING | NEW YORK<br />20 | RESEARCH | DALLAS<br />30 | SALES | CHICAGO<br />40 | OPERATIONS | BOSTON</p><p>development:<br />&nbsp; adapter:&nbsp; oracle<br />&nbsp; host:&nbsp; &nbsp; &nbsp;localhost<br />&nbsp; database: CP<br />&nbsp; username: scott<br />&nbsp; password: t</p><p>But the following fails ..<br />rake db:migrate<br />----------------- unable to locate component&nbsp; {msvcrt-ruby18.dll was not found } -- <br />(in C:/Documents and Settings/cp/Desktop/test)<br />rake aborted!<br />undefined method `define_a_column&#039; for class `OCI8::Cursor&#039;</p><p>Any clue, what iam missing ?</p><p>Thanks</p>]]></summary>
			<author>
				<name><![CDATA[cp]]></name>
				<uri>http://railsforum.com/profile.php?id=24751</uri>
			</author>
			<updated>2010-02-09T07:25:15Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37114&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Routing to namespace]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37166&amp;action=new"/>
			<summary type="html"><![CDATA[<p>I have an application where I have blog posts that must be routed to /blog. I generated a scaffold as follows:</p><div class="codebox"><pre><code>ruby script/generate scaffold &#039;blog/post&#039; string:title text:body</code></pre></div><p>This created a posts_controller within app/controllers/blog, model posts.rb in app/models/blog and a table blog_posts in the database. The contents of the controller and are:</p><div class="codebox"><pre><code># app/controller/blog/posts_controller.rb
class Blog::PostsController &lt; ApplicationController
  # REST actions
end

# app/models/blog/posts.rb
class Blog::Post &lt; ActiveRecord::Base
end

# config/routes.rb
  map.namespace &#039;blog&#039; do |blog|
    blog.resources :posts
  end</code></pre></div><p>When I ran rake routes, I got the following:</p><div class="codebox"><pre><code>    blog_posts GET    /blog/posts(.:format)               {:controller=&gt;&quot;blog/posts&quot;, :action=&gt;&quot;index&quot;}
               POST   /blog/posts(.:format)               {:controller=&gt;&quot;blog/posts&quot;, :action=&gt;&quot;create&quot;}
 new_blog_post GET    /blog/posts/new(.:format)           {:controller=&gt;&quot;blog/posts&quot;, :action=&gt;&quot;new&quot;}
edit_blog_post GET    /blog/posts/:id/edit(.:format)      {:controller=&gt;&quot;blog/posts&quot;, :action=&gt;&quot;edit&quot;}
     blog_post GET    /blog/posts/:id(.:format)           {:controller=&gt;&quot;blog/posts&quot;, :action=&gt;&quot;show&quot;}
               PUT    /blog/posts/:id(.:format)           {:controller=&gt;&quot;blog/posts&quot;, :action=&gt;&quot;update&quot;}
               DELETE /blog/posts/:id(.:format)           {:controller=&gt;&quot;blog/posts&quot;, :action=&gt;&quot;destroy&quot;}</code></pre></div><p>But when I go to http://localhost:3000/blog/posts, I get the following error:</p><div class="codebox"><pre><code>Mysql::Error: Table &#039;myproject.posts&#039; doesn&#039;t exist: SELECT * FROM `posts` </code></pre></div><p>It&#039;s looking for a table called posts, but I need it to use the blog_posts table. Could somebody point me in the right direction, please?</p>]]></summary>
			<author>
				<name><![CDATA[nithinbekal]]></name>
				<uri>http://railsforum.com/profile.php?id=31080</uri>
			</author>
			<updated>2010-02-09T06:54:53Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37166&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Autocomplete Association + Live Search]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=23273&amp;action=new"/>
			<summary type="html"><![CDATA[<p>My first tutorial. There may be many better ways to do this and add on to this. And thats exactly what im hoping will come out of this post. Ive been digging around and have been helped by a lot of people with this. <br />These are the models we have<pre name="code" class="ruby:nogutter">Company has_many Contacts<br />Contact belongs_to Company<br />Contact has_many Reminders<br />Reminder belongs_to Contact</pre><br />The idea is to send a Reminder to a contact via email. This is the work flow that this tutorial is going to cover.<br />1.User starts typing either the contact&#039;s name or contact&#039;s email into the &#039;To&#039; field.<br />2.Autocomplete kicks off and returns matching contacts.<br />3.User scrolls down options and selects the one he/she wants.<br />4.Selected option appears on the text box<br />&nbsp; &nbsp;4a. Only the name appears in the text box. But name, email address and company name are shown in the options list.<br />5.A live search runs and updates an adjacent div with more details about the chosen contact and his employer(the associated Company model).<br />6. When the form is submitted, the Reminder created should carry the id of the Contact it was sent to as the foreign key (ie) the association should be created. I followed Ryan Bates tutorial - Railscasts episode 102 - Autocomplete Association for this one.<br />You will have to install the auto_complete plugin before you start if you are running Rails 2 or above.<pre name="code" class="ruby:nogutter">script/plugin install <a href="http://svn.rubyonrails">http://svn.rubyonrails</a>. org/rails/plugins/auto_complete</pre><br />Now, the code. Starting with the view. app/views/reminders/_reminder.rhtml.erb<pre name="code" class="ruby:nogutter">&lt;%#Autocomplete Association%&gt;<br />To: &lt;%= text_field_with_auto_complete :reminder, :contact_name, {:size =&gt; 50}, {:skip_style =&gt; false, :url =&gt; list_contacts_path(), :method =&gt; :get,:with =&gt;&quot;&#039;reminder_contact_name=&#039; + element.value&quot;}%&gt;&lt;br/&gt;<br />&lt;br&gt;</p><p>&lt;%#Live search%&gt;<br />&lt;%=image_tag(&quot;/images/spinner.gif&quot;,&nbsp; &nbsp; <br />:align =&gt; &#039;absmiddle&#039;,<br />:border =&gt; 0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />:id =&gt; &#039;spinner&#039;,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />:style =&gt; &quot;display: none;&quot;) %&gt;<br />&nbsp; &nbsp;<br />&lt;%= observe_field &#039;reminder_contact_name&#039;,&nbsp; &nbsp; &nbsp;</p><p>:frequency =&gt; 0.5,<br />:update =&gt; &#039;contact&#039;,<br />:before =&gt; &quot;Element.show(&#039;spinner&#039;)&quot;,<br />:success =&gt; &quot;Element.hide(&#039;spinner&#039;)&quot;,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />:url =&gt; list_companies_path(),:method =&gt;:get,<br />:with =&gt; &#039;reminder_contact_name&#039; %&gt;<br />Contact info:<br />&lt;div id=&quot;contact&quot;&gt;&lt;/div&gt;</pre><br />A few points here <br />-text_field_with_autocomplete is a helper method that comes with the plugin. <br />-most tutorials suggest setting :skip_style =&gt; true to override the default CSS styles in case you are writing your own CSS. The default CSS is good enough for me. Incidentally, if i set it to false, i get the results listed but the surrounding wrapper and the highlighting of selected options etc are gone. For the record.<br />-list_contacts_path is the controller action that is going to return matched results. Its a REST url and the method :get needs to be specified.<br />-:with is the option that lets you pass the parameters. &#039;reminder_contact_name&#039; is just a variable name and can be anything you want. element.value gives the value entered in the field.<br />-download the spinner image if you have not got it and put it in the public/images folder for the live search.<br />-observe_field updates the &#039;contact&#039; div. notice the :with option. Setting it to the field name sends the value in that field under the same name as parameter.<br />controller code for autocomplete. app/controllers/contacts_controller.rb<pre name="code" class="ruby:nogutter"> def list<br />&nbsp; &nbsp; @contacts = Contacts.find(:all, :conditions =&gt; [&#039;name LIKE ? OR email LIKE ?&#039;, &quot;%#{params[:reminder_contact_name]}%&quot;, &quot;%#{params[:reminder_contact_name]}%&quot;])<br />&nbsp; &nbsp; if request.xml_http_request?<br />&nbsp; &nbsp; &nbsp; render :partial =&gt; &quot;list&quot;, :layout =&gt; false<br />&nbsp; &nbsp; end<br />&nbsp; end</pre><br />the query is designed to match the contact_name as well as the email. renders the list partial. setting :layout=&gt;false is important to avoid getting your application layout or other default layout rendered along with the autocomplete results.<br />app/views/contacts/_list.js.erb<pre name="code" class="ruby:nogutter">&lt;ul&gt;<br />&lt;%- for contact in @contacts do -%&gt;<br />&lt;li&gt;&lt;%=h contact.name %&gt;<br />&nbsp; &nbsp; &lt;div class=&quot;informal&quot;&gt;&lt;%=h contact.email %&gt;|&lt;%=h contact.company.name %&gt;&lt;/div&gt;&lt;/li&gt;<br />&lt;%- end -%&gt;<br />&lt;/ul&gt;</pre><br />This shows the contact name, the email, and the company the contact belongs to. You can pretty much show anything you want here using @contacts but its a good idea to show only distinguishing details in autocomplete results.<br />Setting the div class to &#039;informal&#039; takes care of step 4a (ie) set div class to informal for those fields that you do not want to appear on the text box when an option is selected.<br />Now the controller code for the live search.<br />app/controllers/companies_controller.rb<pre name="code" class="ruby:nogutter">def list<br />&nbsp; &nbsp; &nbsp; &nbsp; unless params[:reminder_contact_name].blank?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @contact = Contacts.find_by_name(params[:reminder_contact_name])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if @contact<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@company = @contact.company<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; end&nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if request.xml_http_request? <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if !@company.blank?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; render :partial =&gt; &quot;show&quot;, :layout =&gt; false<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elsif params[:reminder_contact_name].blank?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; render :text =&gt; &quot;Please enter a contact&#039;s name or email address&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elsif @company.blank?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; render :text =&gt; &quot;Info not found for &#039;#{params[:reminder_contact_name]}&#039;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; render :text =&gt; &quot;Please select a contact&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end&nbsp; &nbsp; <br />&nbsp; &nbsp; end</pre><br />The second half of the code here isnt really very pretty. Was trying to cover various possible states of the live search. Definitely an area that can use polishing up.<br />app/views/companies/_show.js.erb<pre name="code" class="ruby:nogutter">&lt;ul&gt;<br />&lt;li&gt;Company name: &lt;%=h @company.name %&gt;&lt;/li&gt;<br />&lt;li&gt;Address : &lt;%=h @company.address_1%&gt; &lt;%=h @company.address_2%&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;%=h @company.city%&gt; &lt;%=h @company.state%&gt; &lt;%=h @company.country%&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;%=h @company.zip%&gt;&lt;/li&gt;<br />&lt;/ul&gt;</pre><br />Again, you can show pretty much anything you want here using the @company instance variable.<br />One last piece of code. The contact_name field in the autocomplete is not really an attribute of the reminder model. Its a virtual attribute. So this virtual attribute needs a getter and setter method in the Reminder model.<pre name="code" class="ruby:nogutter">def contact_name<br />&nbsp; &nbsp; contact.name if contact<br />&nbsp; end<br />&nbsp; <br />&nbsp; def contact_name=(name)<br />&nbsp; &nbsp; unless name.blank?<br />&nbsp; &nbsp; &nbsp; self.contact = Contacts.find_by_name(name) <br />&nbsp; &nbsp; &nbsp; if self.contact.blank? <br />&nbsp; &nbsp; &nbsp; &nbsp; self.contact = Contacts.find_or_create_by_email(name) <br />&nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; end<br />&nbsp; end</pre><br />I have not tested the find_or_create_by in this. What it should do is, if the contact with the given name is not found, it searches for a contact with the given email. If it does not find one, it creates a Contact with that email. And the Reminder is sent to that email address. This I am doing to make the process of sending a Reminder, either to an existing or new contact, as easy and seamless as possible for the user.<br />One other gotcha. Dont use too many divs in the partials that render the results of the autocomplete and live search. It does not work in Safari. <br />Except for that, this code works with Safari(latest), FF(latest), IE7 and IE6. I hope i have covered everything. <br />Thanks to Duplex, Xavier Noria, Neil and of course Ryan Bates for their direct/indirect help with this.<br />Some other stuff you might wanna refer.<br /><a href="http://groups.google.co.in/group/rubyonrails-talk/browse_thread/thread/5a91ddc41c1c44d9/42484362ee3b0df5?lnk=gst&amp;q=autocomplete&amp;pli=1">http://groups.google.co.in/group/rubyon &#133; &amp;pli=1</a><br /><a href="http://railsforum.com/viewtopic.php?id=22902">http://railsforum.com/viewtopic.php?id=22902</a><br /><a href="http://railscasts.com/episodes/102-auto-complete-association">http://railscasts.com/episodes/102-auto &#133; ssociation</a></p><p>And finally, the small problem that I am yet to fix. In the setter method for the virtual attribute contact_name, i need to scope the query through current_user. but current_user is a helper method. And the params hash(which carries the current_user_id in my case) too is not available in the model. Hope someone can help me out with that. Details <a href="http://railsforum.com/viewtopic.php?id=23201">here</a>.</p>]]></summary>
			<author>
				<name><![CDATA[yourstruly_vinay]]></name>
				<uri>http://railsforum.com/profile.php?id=13570</uri>
			</author>
			<updated>2010-02-09T06:26:23Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=23273&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Data tables with sorting, filters, and search]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=35971&amp;action=new"/>
			<summary type="html"><![CDATA[<p>I am extremely new to rails. I know that when working with other frameworks there is often a widget that can be evoked to query the database and return a data table in HTML. The returned code often includes sorting, filtering, and searching capabilities.</p><p>I don&#039;t know what to call this or where to look. After googling for a while, the best I could find is that it might have something to do with active record. Am I in the wrong place? If so, do you know what I am talking about and can you offer some suggestions?</p>]]></summary>
			<author>
				<name><![CDATA[Ritesh Kumar]]></name>
				<uri>http://railsforum.com/profile.php?id=32434</uri>
			</author>
			<updated>2010-02-09T05:25:35Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=35971&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[[SOLVED] roo isn't working on production]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?id=37165&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi, I have installed roo on my localhost(I&#039;m running on windows) by just doing the usual gem install. Back then it was still version 1.2.0.</p><p>Now, I place my files on the server for production environment mode which is in Ubuntu. I have my rails to version 2.0.1 and my roo to 1.9.2 and 1.2.0</p><p>When I loaded my application, roo dependent controllers would start throwing 500.html and would only work if I comment out the require &#039;roo&#039; line.</p><p>On my log is the following:<br />- MissingSourceFile (no such file to load -- google_spreadsheet):</p><p>Here are my gems installed<br /></p><div class="codebox"><pre><code>*** LOCAL GEMS ***

actionmailer (2.1.0, 2.0.1)
actionpack (2.1.0, 2.0.1)
activerecord (2.1.0, 2.0.1)
activeresource (2.1.0, 2.0.1)
activesupport (2.1.0, 2.0.1)
bones (3.2.1)
builder (2.1.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
ezcrypto (0.7.2)
fcgi (0.8.8)
GData (0.0.4)
gemcutter (0.3.0)
google-spreadsheet-ruby (0.1.1)
gruff (0.3.6)
hoe (2.5.0)
hpricot (0.8.2)
json_pure (1.2.0)
Linguistics (1.0.5)
little-plugger (1.1.2)
loquacious (1.4.2)
mysql (2.8.1)
nokogiri (1.4.1)
oauth (0.3.6)
parseexcel (0.5.2)
racc (1.4.6)
rack (1.1.0)
rails (2.1.0, 2.0.1)
rake (0.8.7)
rake-compiler (0.7.0)
rexical (1.0.4)
rmagick (2.12.2)
roo (1.9.2, 1.2.0)
ruby-hmac (0.4.0)
ruby-ole (1.2.10)
rubyforge (2.0.3)
rubygems-update (1.3.5)
rubyzip (0.9.1)
spreadsheet (0.6.4.1)</code></pre></div><p>as of now I comment all the roo required lines and codes. but I need to find a solution for this. Any help?<br />THanks!</p>]]></summary>
			<author>
				<name><![CDATA[ajibanda]]></name>
				<uri>http://railsforum.com/profile.php?id=14875</uri>
			</author>
			<updated>2010-02-09T04:39:48Z</updated>
			<id>http://railsforum.com/viewtopic.php?id=37165&amp;action=new</id>
		</entry>
</feed>
