Hey guys,
I’m trying to use Ruby on Rails w/ Ajax… I’m getting a funky little
problem. So I’ve got an observer on a text field called username and I’m
trying to just check to see if the username is already in the DB or not,
then display the appropriate message. Here’s the form part in my RHTML
file:
<%= text_field_tag :username %>
<%= observe_field(:username, :frequency => 0.25,:update =>
:div_username,:url => { :action => :checkUsername }) %>
…my controller
def checkUsername
if(User.checkUsername(params[:username])==1)
render :text => “#{params[:username]} is not available”
else
render :text => “available”
end
end
The problem is that params[:username] is never set!! When I look at
whats going on the backend, it shows me that username I typed in is the
param name! For example, if I typed in “jsmith” into the username field,
it sends param[:jsmith]=>nil to the controller. I’m really confused, if
anyone could help me figure this out, I’d really appreciate it!
Thanks,
- Jeff