Topic: Auto_complete plugin

Hello,
I'm using the auto_complete plugin modified for named_scope. I have a feeling this question is not at all related to the plugin, but to my lack of rails understanding.

In my controller, I have this:

   
    auto_complete_for :skill, :name do |list, params|
        list.scoped( {:conditions=>[

Re: Auto_complete plugin

looks like your post was cutoff due to the use of a square bracket. Please repost, and put your code in side the code tags:

[ code ]
def my_method
  puts "hello"
end
[ /code ]

becomes:

def my_method
  puts "hello"
end

Re: Auto_complete plugin

Yikes, sorry about that:

  auto_complete_for :skill, :name do |list, params|
        list.scoped( {:conditions=>("id=?", @user.id)})

Re: Auto_complete plugin

the brackets are formatted correctly, but I had other square brackets that were throwing it off.

Basically, @user is null up there; however, if I use the user's int value, it works perfectly. I'm sure I'm missing something as to how ruby/rails works, but is there any way to use a dynamic @user up there?

Also, love the avatar!!!

Re: Auto_complete plugin

Never mind, I figured it out. For any rails noobs like me:

auto_complete_for actually makes it's own method when the page is loaded, hence, my auto_complete_for actually turned into auto_complete_for_tag_name. That means that you can overload your view with

:url=>{:action=>'auto_complete_for_tag_name, :paramname=>whatever}}

Then, you can go back into your controller and do this:

  auto_complete_for :skill, :name do |list, params|
        list.scoped( {:conditions=>("id=?", params(:paramname))})

except, format it correctly (I'm skeptical of railsforum's formatting)

Thanks for forcing me to figure it out, it was well worth it!