I have a form containing a text field along the lines of:
<%= form_for(wizard, :url => wizard_path, :method => :put) do |f| %>
....
<%= form.text_field "gas_credentials[user_id]", :value =>
wizard.gas_credentials['user_id'] %>
....
<% end %>
Mysteriously, when wizard.gas_credentials is nil, the text_field gets
initial text equal to the current_user.email (which in this case is
admin@admin.com). At the very least, I'd expect an error trying to call
[] on nil.
What's especially odd is that the wizard model knows nothing about
current_user, so I don't see where it's getting that value from. Can
anyone shed light on what might be happening, or at least how text_field
decides to compute its :value?
TIA
- ff
P.S.:
% rake about
About your application's environment
Ruby version 1.9.2 (x86_64-darwin10.6.0)
RubyGems version 1.3.7
Rack version 1.2
Rails version 3.0.5
Environment development
... and I'm using devise 1.4.2 and warden 1.0.4
on 2011-11-08 01:21
on 2011-11-08 01:33
Doh! The answer: browser autocompletion. I'm leaving this post in place rather than deleting it out of shame in the faint hope that it might save someone else a few minutes of head scratching.
on 2011-11-08 01:50
[silly forum code won't let me edit previous reply.]
To prevent autocompletion, you can do something like:
<%= form.text_field "gas_credentials[user_id]",
:value => wizard.gas_credentials['user_id'],
:autocomplete => :off
%>
on 2011-11-08 07:36
On 8 November 2011 00:50, Fearless Fool <lists@ruby-forum.com> wrote:
> [silly forum code won't let me edit previous reply.]
That's because it's a mailing list... and even if every other
subscriber let you come around to their house and edit their emails, I
wouldn't ;-)
The "ruby-forum" is just a wrapper for the Google Groups list.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.