Text_field_with_auto_complete doesn|t work in edit/show view

Hi,

I am using the autocomplete for text field with ‘Scriptaculous’ and it
works perfectly fine in “new” action.

All the examples I see are only for the “new” action.

But doesn’t default to the selected value/text in “edit/show” action? Is
this possible or should I write custom code for “edit/show” action?

Thanks, Hari

On Monday, June 19, 2006, at 3:22 PM, Nara H. wrote:

Thanks, Hari


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

I’ve used it recently for edit views as well as new views with no
issues.

_Kevin

Nara H. wrote:

My code in “_form.html” looks like:

Reseller Location
<%= text_field_with_auto_complete :state, :state_name, {:size => 50} %>

and in controller:
auto_complete_for :state, :state_name

Is the field on state called ‘state_name’ or ‘name’ ?

Alan

Kevin O. wrote:

Hi Kevin,

Thanks for the reply.

My code in “_form.html” looks like:

Reseller Location
<%= text_field_with_auto_complete :state, :state_name, {:size => 50} %>

and in controller:
auto_complete_for :state, :state_name

In my ‘reseller’ model I have an ID for the state and the ID is to be
looked up from the “state” model.

This code works fine in “new” action but doesn’t get the default state
name in edit/show action?

How does your model look like? Is the usage any different?

Thanks,Hari

On Monday, June 19, 2006, at 3:22 PM, Nara H. wrote:

Thanks, Hari


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

I’ve used it recently for edit views as well as new views with no
issues.

_Kevin

Nara H. wrote:

state_name

_Hari

It could be that somethings getting confused there as, ISTR, the form
field names use underscores to separate the object and field.

How hard (or easy) would it be for you to rename the column as ‘name’ or
‘statename’ and retry ? Would there be much code to change ?

Note this is all supposition, so if it’s a lot of work, don’t do it as
I’ve zero guarantee of success :slight_smile:

Alan

state_name

_Hari

Alan F. wrote:

Nara H. wrote:

My code in “_form.html” looks like:

Reseller Location
<%= text_field_with_auto_complete :state, :state_name, {:size => 50} %>

and in controller:
auto_complete_for :state, :state_name

Is the field on state called ‘state_name’ or ‘name’ ?

Alan

It was not a big deal to change the column name, but I still couldn’t
get it working in show/edit view.

How does your model & code for “_form.rhtml” looks like?

Thanks.

_Hari

On Monday, June 19, 2006, at 4:03 PM, Nara H. wrote:

Thanks,Hari

What do you get when you do this…

<%= debug(@state) %>
in your _form.rhtml file

and call it with the ‘new’ or ‘show’ actions?

_Kevin

Kevin O. wrote:

On Monday, June 19, 2006, at 4:03 PM, Nara H. wrote:

What do you get when you do this…

<%= debug(@state) %>
in your _form.rhtml file

and call it with the ‘new’ or ‘show’ actions?

_Kevin

When I add the debug statement I get nothing, only “—”. What
information should this bring…even in “new” it shows only the hyphens.

_Hari

Nara H. wrote:

It was not a big deal to change the column name, but I still couldn’t
get it working in show/edit view.

How does your model & code for “_form.rhtml” looks like?

Thanks.

_Hari

Sorry Hari,

I don’t have one, I’m working from memory while here at my (Java) day
job.

A.

On Monday, June 19, 2006, at 10:46 PM, Nara H. wrote:


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Your @state variable is probably not being set properly by the
controller. This would explain why the autocomplete is failing.

load a default or create a blank one.

_Kevin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs