[Rails] auto_complete plugin
I have a method in my controller that would apply to all fields that
use the auto_complete plugin
def auto_complete_for
object = params[:id].split('_')[0]
method = params[:id].split('_')[1]
table = object.to_s.camelize.constantize.table_name
object.to_s.camelize.constantize::init( @lang )
tables = object.to_s.camelize.constantize::tables
if tables.include?( "#{table}_#{method}" )
etc...
So in my template I have:
<%=text_field_with_auto_complete :sample, c, {:skip_style=>true} %>
but the ajax request is not right. It says
http://localhost:3000/echantillons/auto_complete_for_sample_technique
and the parameters are
Parameters: {"sample"=>{"technique"=>"test"}}
whereas I think it should say
http://localhost:3000/echantillons/auto_complete_for/sample_technique
with parameters {"id"=>{"sample_technique""}}
What am I doing wrong?
--
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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home