Re: [Rails] Sql Script Doubt
On Oct 3, 2012, at 6:33 AM, BalaRaju Vankala wrote:
> Hello everyone,
>
> I am having a doubt regarding sql in rails .. i kept the autocomplete feature in my application .. but the problem is there should not be repitition in the term in the text field... This is what i done ....
>
>
> class SkillsController < ApplicationController
>
> def index
> term = (params[:term].split(",").last || "").strip
>
> @skills = Skill.order(:name).where('name LIKE?', "%#{term}%")
>
> render :json => @skills.map(&:name)
> end
>
> Can anyone please help.... ASAP
>
I'm usually against answering ASAP questions, but have you tried adding .uniq at the end of your @skills query?
Walter
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home