Because you’ve hand-coded the field you’re asking Rails to observe.
Rails
is server-side technology that generates the html and/or js to send to
the
browser. But it only concerns itself with the stuff you tell it you
want it
to concern itself with. You tell it that by using erb (embedded ruby)
in
your view files. Any html you hand-code just gets passed straight
through
to the browser. So in the case of your observe_field, Rails has no
knowledge of the form element you’re asking it to generate js to
observe.
It’ll get worse if you’ve hand-coded the form tags too.
If you’re new to Rails, especially if you’re coming from something like
PHP,
you’d really benefit from working through a tutorial or two to get the
hang
of how things work together. At the risk of self-promotion, we just did
a
rewrite of Curt Hibb’s “Rolling with Ruby on Rails” tutorial to bring it
up
to date with current (or at least near current) syntax / practices.
It’s
at:
I hope you find it helpful. And welcome to Rails!
Best regards,
Bill
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.