> Not to send this thread spinning off into another universe, but: it
> seems that in a number of Rails methods, one or more arguments is a
> Hash. No problem with it in principle, but it's not transparent
> ("discoverable") from the signature what values will do what. For
> comparison, with Java + Eclipse, it's clear what data should be sent
> to the method.
>
> I'm quite enamored with Rails, but this point is the hardest
> adjustment coming from a statically-typed language.
It's quite easy once you understand how it works.
As syntactic sugar Ruby builds a single hash from any trailing
hash-like arguments and passes *it* as the corresponding positional
argument. For example in
def foo(x, y=0)
...
end
the call
foo(:a => 1, :b => 2, :c => 3)
is equivalent to
foo({:a => 1, :b => 2, :c => 3})
and both of them result in
x = {:a => 1, :b => 2, :c => 3}
y = 0
In that situation, how can you pass a -7 for y? You have to make
explicit the 1st argument:
foo({:a => 1, :b => 2, :c => 3}, -7)
That's the basic stuff. Other than that what you need to do with those
helpers, as with any other API, is to read its documentation. In
particular their signature.
>
> After some further tinkering, I'm able to get 'goodguy' and 'badguy'
> values passed to the controller (the 'method per id' is far from
> ideal....):
>
don't forget to use encodeURIComponent or bad things will happen if
you type & into the box.
Fred
Hi all,
Has anybody done anything with this code? I am trying to use it and I am
not sure if it works. I have made a few changes but seem to be crawling
deeper and deeper into a bottomless hole. My issue is that I have
several divs with the same auto_completer for each and all within
different forms and all located on the same page. The issue became that
when I used the auto_completer on a div located lower on the page it
appeared not to work, when in fact it did work, it was just populating
the list higher up on the page (because the id fields were named the
same), which is why I needed to re-name each auto_completer with a
unique name. My code looks like:
View
-----
<div id = "clone_to_div">
Clone to Pseudocity: <%=
text_field_with_auto_complete_with_id_checking
:enpseudo, :pseudocity, {:id => 'enpseudo_service_fees'},
{:skip_style => true} %>
</div>
<%= link_to_remote( '<span>Clone</span>',
{:submit => 'clone_to_div', :update => 'clone_fee_div',
:complete => 'new Effect.Pulsate(\'clone_fee_div\');',
:url => {:action => 'clone_pseudo_fee', :pseudo_id => @pseudo.id}
}, :class => 'squarebutton') %>
The issue that I am having is that when the form is submitted nothing
from the auto_complete is submitted. One issue that I have noticed from
the HTML generated code is that the <input ... /> has the correct id but
an incorrect name. So, I did as suggested and gave it a name via the
tag_options and that's when things started to go south. By supplying a
name the auto_complete_field seems to stop working all together. Remove
it and it works but nothing gets passed along in my post - this seems to
be a catch-22.
Any suggestions on what I am doing wrong or can someone point me in the
right direction? Thanks for any and all help,
-S
--
Posted via http://www.ruby-forum.com/.
Never mind, my fault. I had multiple "clone_to_div" that was causing the
issue. Once I remained these div to have unique id's all issues went
away.