I did a search and found a reference to what I need help with but it
doesn’t seem to work for me. I’m having trouble getting a value for a
checkbox and testing it in my controller. (I’m not sure what the
problem is since I have no trouble getting the other form field
values.) Some help in what I’m doing wrong would greatly be
appreciated.
The form contains a field like so:
different billing
address
In my controller I reference it like so:
billing_address_hash = Hash.new()
if (params[:different_billing_info] == “1”)
billing_address_hash.merge(params[:billing_address])
else
billing_address_hash.merge(params[:customer])
# Remove customer fields not found in the billing address table
billing_address_hash.delete(‘uva_status’)
billing_address_hash.delete(‘email’)
end
I saw a prior posting to getting the checkbox value with a checked
associative array index, ie.
if (params[:different_billing_info][‘checked’] == “1”)
But this seemed to make no difference. No matter what the value of the
checkbox is, the first part of the if statement above is executed.
I even tried adding a hidden field to the form based on an example I
saw:
different billing
address
which does in fact have the value passed be either 1 or 0 depending on
if it is checked or not. I see this in looking at the contents of the
Parameters hash.
and I get it as params[:query][all_categories] => ‘0’ or ‘1’
unselected/selected
btw, my problem is having the disabled value (true/false) depending
upon the check_box value…
it seems I cannot write and evaluate a block : { @query.
all_categories == “0” } giving true or false…
what does development.log say about the content of
params[:different_billing_info] ? is it “1” or not?
I second that. That log is your best friend. I have a similiar form
where I have a whole slew of checkbox. The way you have the input named
it might be coming through as:
The problem is that neither the contents of the customer hash nor the
billing_address hash from the form is used to write to the
billing_address table. From the log this is what’s getting written to
the table, which is the existing content of the table and what was
previously in the form field before the checkbox was updated:
[4;35;1mBillingAddress Update (0.000971)
I’m starting to think there’s nothing wrong with the form parameter
value and there must be a logic problem someplace else or some other
coding issue because I always see the correct data in the params field
in the log file but that’s not what the SQL is using. But my first
thought was that it was the checkbox. If I’m using the
params[:different_billing_info] is the correct way to refer to this,
then I’ll move onto further debugging. I just wanted to rule this out
as the problem.
Any suggestions as to a good way for debugging code/logic that doesn’t
necessarily show up in the log files?
(If you haven’t figured out, I’m relatively new to RoR. Done some
reading and working on a single complex web form that will write data
to a handful of different tables.)
i dont know anything about checkbox…i have following requirement…
checkbox along with mail ids…whenever i click on first checkbox all the
mails needs to get selected…then for those mails i need to send mail in
ruby…dnt have knoweldge about rails.can anyone tell me what codes i
need to insert in controller and views in briefly
i dont know anything about checkbox…i have following requirement…
checkbox along with mail ids…whenever i click on first checkbox all the
mails needs to get selected…then for those mails i need to send mail in
ruby…dnt have knoweldge about rails.can anyone tell me what codes i
need to insert in controller and views in briefly
Is this a modification to an existing application or are you asking
how to write a new applications with this functionality?
You say you you don’t know about rails, what experience do you have
with web development or other languages?
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.