[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Simple Check Box Question

Matt Koidin

6/17/2005 4:47:00 PM

I'm new to ruby and rails and I have a simple question that is driving
me crazy. I have a group of check boxes and I want to be able to
default check some of them based on entries in a database.

My display.rhtml looks like this:

<% for category in @categories %>
<dd><%= check_box "category", category.id %><%= category.name %></dd>
<dt>&nbsp;</dt>
<% end %>

If I was writing in HTML I would add a CHECKED option to the checkbox
tag to have it default to checked. How do I do that with ruby?

Thanks,
Matt

14 Answers

derekgr

6/17/2005 10:07:00 PM

0

It's the third parameter to the call you're making, a boolean. False is
not checked, true is checked.

http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagH...

i.e., in your above example,
<%= check_box "category", category.id, category.my_boolean_attribute?
%>
Would check the checkbox if category.my_boolean_attribute? returned
true and would leave it unchecked otherwise.

Matt Koidin

6/21/2005 1:53:00 AM

0

I tried that and it doesn't work (again, I might be misinterpreting the
syntax).

If I write:

<%= check_box "category", category.id, true %>

I get an error that says:

undefined method `stringify_keys' for true:TrueClass

Matt Koidin

6/21/2005 3:34:00 AM

0

I solved the problem --

I switched to using <input type=checkbox> and mimic'd the the hidden
field that the check_box tag gives you.

Devin Mullins

6/21/2005 12:22:00 PM

0

Matt Koidin wrote:

>I solved the problem --
>
>I switched to using <input type=checkbox> and mimic'd the the hidden
>field that the check_box tag gives you.
>
>
Mehh.... Evil... A look at the documentation says how to do it:

http://api.rubyonrails.com/classes/ActionView/Helpers/FormHelper.ht...

*check_box*(object, method, options = {}, checked_value = "1",
unchecked_value = "0")

Returns a checkbox tag tailored for accessing a specified attribute
(identified by method) on an object assigned to the template (identified
by object). It's intended that method returns an integer and if that
integer is above zero, then the checkbox is checked. Additional options
on the input tag can be passed as a hash with options. The checked_value
defaults to 1 while the default unchecked_value is set to 0 which is
convenient for boolean values. Usually unchecked checkboxes don't post
anything. We work around this problem by adding a hidden value with the
same name as the checkbox.

So your category_id seems to be in the wrong place.

Devin


Jeff Waltzer

6/21/2005 6:49:00 PM

0

My apologies if this is a excessively newbish question.
Is there way to get one's rails app loaded into fxri such that I can use it
with Rails to explore what I can do with the different objects of my Rails
application?

Jamis Buck

6/21/2005 7:17:00 PM

0

On Jun 21, 2005, at 12:48 PM, Jeff Waltzer wrote:

> My apologies if this is a excessively newbish question.
> Is there way to get one's rails app loaded into fxri such that I
> can use it
> with Rails to explore what I can do with the different objects of
> my Rails
> application?
>

Not having used fxri before, it should just be a matter of requiring
your config/environment.rb file. Once you do that, you should have
all of your Rails app before you, ready to query.

- Jamis


Lothar Scholz

6/22/2005 4:15:00 AM

0

Hello Jeff,

JW> My apologies if this is a excessively newbish question.
JW> Is there way to get one's rails app loaded into fxri such that I can use it
JW> with Rails to explore what I can do with the different objects of my Rails
JW> application?

Yes you can use "rdoc --ri <your-rails-app-dir>" and it will generate
the data for the database. But make sure that you don't extend
existing classes like STRING as they are removed.

I work on an easy way to do so with "Arachno Ruby" as the current
ri/rdoc implementation is not the best.


--
Best regards, emailto: scholz at scriptolutions dot com
Lothar Scholz http://www.ru...
CTO Scriptolutions Ruby, PHP, Python IDE 's




Hal E. Fulton

6/22/2005 4:19:00 AM

0

Jeff Waltzer wrote:
> My apologies if this is a excessively newbish question.

[snip]

I can't answer your question -- hopefully others already have --
but I will comment that newbie questions are welcome here.


Hal



Dan Christensen

7/2/2010 4:37:00 AM

0

On Jul 1, 4:15 am, PL <pl.nos...@pandora.be> wrote:
> On 1/07/2010 7:03, Dan Christensen wrote:> On Jun 30, 3:29 pm, PL<pl.nos....@pandora.be>  wrote:
> >> Amnesty International says Cuba stepping up repression of independent media
>
> > AI also recently reported:
>
> (snip)
>

What the cowardly apologist PL snipped and refused to address:

"The US government is acting CONTRARY to the Charter of the United
Nations by restricting the direct import of medicine and medical
equipment and supplies, and by imposing those restrictions on
companies operating in third countries."

“The RESTRICTIONS IMPOSED BY THE EMBARGO help to deprive Cuba of vital
access to medicines, new scientific and medical technology, food,
chemical water treatment and electricity.”

"The US embargo against Cuba is IMMORAL and should be lifted. It’s
preventing millions of Cubans from benefiting from vital medicines and
medical equipment essential for their health."

"Amnesty International calls on the US Congress to take, WITHOUT
FURTHER DELAY, the necessary steps towards lifting the economic,
financial and trade embargo against Cuba."

http://www.amnesty.org/en/library/asset/AMR25/002/2009/en/e7b1efe4-27f4-4b2c-9a39-23c88749e39e/amr250022...
http://www.amnesty.org/en/news-and-updates/report/president-obama-should-take-lead-lifting-embargo-against-cub...
http://www.amnesty.org/en/library/asset/AMR25/007/2009/en/51469f8b-73f8-47a2-a5bd-f839adf50488/amr250072...
(PDF format)

Article 2c of the UN Genocide Convention states that the crime of
genocide includes, among other things, "deliberately inflicting on the
group conditions of life calculated to bring about its physical
destruction in whole or in part."

http://www2.ohchr.org/english/law/ge...

Again, as Amnesty International has reported, “The restrictions
imposed by the embargo help to deprive Cuba of vital access to
medicines, new scientific and medical technology, food, chemical water
treatment and electricity.” These are deliberate acts, the only
purpose of which can be to bring about the physical destruction of the
Cuban people in whole or in part. These cruel sanctions can,
therefore, even be seen as a form of genocide under international law!
(See footnotes for more detail.)

> Again Dan's abusive and post-edited snippets.

[snip]

Very evasive, Mr. Lobbyist, but thanks for confirming that not even a
die-hard apologist like you can deny that Amnesty International has
condemned your beloved embargo in the strongest possible terms and
called for the immediate and unconditional lifting of these cruel and
inhumane sanctions of yours.


>
> > It puzzles me why AI cannot then understand that Cubans simply cannot
> > allow agents of this genocidal superpower(snip)
>
> Amnesty knows there are no genocidal sanctions and no "agents".

[snip]

Your hysterical screams of denial notwithstanding, I have already
shown that these cruel and inhumane sanctions of yours are indeed a
form of genocide (see the part you snipped above).

As for these "dissidents" of yours being agents, you yourself have
confirmed here, these "dissident" groups of yours would not even exist
without US bankrolling:

"To be able to function they [Cuban dissidents] need aid...They can
only function with international help... The US aid gives them the
means to survive."
http://groups.google.ca/group/soc.culture.cuba/msg/3b60f000...

This has been confirmed by none other than Wayne Smith, US State
Department Veteran and former head of the US Interests Section in
Havana:

"Since 1985, we have stated publicly that we will encourage and openly
finance dissident and human rights groups in Cuba; this, too, is in
our interests. The United States isn't financing all those groups--
only the ones that are best known internationally.

"Those dissidents and human rights groups in Cuba--that are nothing
but a few people--are only important to the extent that they serve us
in a single cause: that of destabilizing Fidel Castro's regime."

Source: Hernando Calvo and Katlijn Declercq, "The Cuban Exile
Movement, Dissidents or Mercenaries," p. 156, Ocean Press, 2000

And according to YOUR OWN posting earlier this month, and the US
regime is to front our "di$$ident" pals to an ADDITIONAL $15 million
this year! Now, we talking only a small handful of people, each
getting perhaps a quarter of a million dollars-- a princely sum by
Cuban standards! Who says crime doesn't pay???

And we know how your di$$ident pals like to lie. See "PL and di$$ident
pal caught in desperate lie"
http://groups.google.com/group/alt.politics.usa/msg/380d876d4b9c...

> Just one example:
>
> Dan claimed on his website (the misquote):
> "Today, for the first time, Amnesty International has explicitly
> denounced the US embargo on Cuba in humanitarian terms, and made clear
> its support for the immediate and unconditional lifting of these cruel
> sanctions"http://members.allstream.net/~dchris/CubaF...
> now moved to:http://www3.sympatico.ca/danchristienses/CubaF...
>
[snip]

Amnesty International recently reported:

"The US embargo against Cuba is IMMORAL and should be lifted. It’s
preventing millions of Cubans from benefiting from vital medicines and
medical equipment essential for their health... Amnesty International
calls on the US Congress to take, WITHOUT FURTHER DELAY, the necessary
steps towards lifting the economic, financial and trade embargo
against Cuba."

Sure sounds immediate and unconditional to me. Once again, we see what
a TRULY desperate liar you are, Mr. Lobbyist!

> The 1948 Geneva Convention on Genocide article 2 is quoted in a very
> misleading way by serial liar Dan Christensen:.

As we see below, you are the one trying to mislead, Mr. Lobbyist.

> The text: (1)
> In the present Convention, genocide means any of the following acts
> committed with intent to destroy, in whole or in part, a national,
> ethnical, racial or religious group, as such:
> (a) Killing members of the group;
> (b) Causing serious bodily or mental harm to members of the group;
> (c) Deliberately inflicting on the group conditions of life
> calculated
> to bring about its physical destruction in whole or in part;

Thanks for confiming I was right. This is precisely what your
political masters have set out to do by "obstructing and constraining
efforts by the Cuban government to purchase essential medicines,
medical equipment and supplies, food and agricultural products,
construction materials and access to new technologies," and by
"preventing millions of Cubans from benefiting from vital medicines
and medical equipment essential for their health." (AI website. See
footnotes.)

While I have asked you literally hundreds of times now -- you snipped
and ran away in terror every time -- it seems even a die-hard
apologist like you cannot deny that such sanctions would lead to the
deaths and needless suffering of children and other vulnerable groups.
Deny it??? Hell, you are counting on it, right, Mr. Lobbyist?

> (d) Imposing measures intended to prevent births within the group;
> (e) Forcibly transferring children of the group to another group.
> The text requires that the acts listed under a-e have been committed
> with "intent to destroy, in whole or in part, a national, ethnical,
> racial or religious group".
> In the case of the US trade sanctions this is clearly not the case.

On the contrary, as we see above, the intent to destroy is clear. Your
beloved embargo deliberately targets Cuban children and other
vulnerable groups (see footnotes) by deliberately "obstructing and
constraining efforts by the Cuban government to purchase essential
medicines, medical equipment and supplies, food and agricultural
products, construction materials and access to new technologies." Your
political masters are fully aware of these abuses -- Amnesty
International and the UN have made sure of that. The regime couldn't
care less, of course. And they continue to inflict these cruel and
inhumane sanctions on the Cuban people. Whatever it takes, right, Mr.
Lobbyist?

> The USA is Cuba's 5th trading partner

[snipping PL's same old Nazi-style lies and rationalizations]

Tell it to the judge, Mr. Lobbyist. Contrary to your lies and
rationalizations here, no amount of US exports (or anything else) is
going to get you off the hook for deliberately "preventing millions of
Cubans from benefiting from vital medicines and medical equipment
essential for their health." The intent to destroy is clear from this
fact alone. Morally and legally, this is genocide.

Dan
Visit my CUBA: Issues & Answers website at http://tiny....

**************
Footnotes

The facts as documented in reports recently released by Amnesty
International (my emphasis):

March 2009

"Amnesty International urges the US government to lift the nearly five-
decade long economic and trade embargo against Cuba as it is
detrimental to the fulfillment of the economic and social rights of
the Cuban people. It OBSTRUCTS AND CONSTRAINS efforts by the Cuban
government to purchase essential medicines, medical equipment and
supplies, food and agricultural products, construction materials and
access to new technologies.

http://www.amnesty.org/en/library/asset/AMR25/002/2009/en/e7b1efe4-27f4-4b2c-9a39-23c88749e39e/amr250022...

September 2009

"The US embargo against Cuba is IMMORAL and should be lifted. It’s
preventing millions of Cubans from benefiting from vital medicines and
medical equipment essential for their health."

"Because of the US embargo, Cuba faces SEVERE RESTRICTIONS in
importing medicines, medical equipment or technologies from the USA or
from any US company abroad. The sanctions also limit other imports to
the island and restrict travel and the transfer of money."

http://www.amnesty.org/en/news-and-updates/report/president-obama-should-take-lead-lifting-embargo-against-cub...

"Amnesty International calls on the US Congress to take, WITHOUT
FURTHER DELAY, the necessary steps towards lifting the economic,
financial and trade embargo against Cuba...

"The US government is acting CONTRARY to the Charter of the United
Nations by restricting the direct import of medicine and medical
equipment and supplies, and by imposing those restrictions on
companies operating in third countries."

"The UN General Assembly has repeatedly CONDEMNED the US embargo as
contrary to the Charter of the United Nations and international law.
On 29 October 2008 the UN General Assembly passed a resolution
reiterating for the 17th time its call on the USA to end its embargo
against Cuba. That resolution was adopted with 185 votes in favour,
three against and two abstentions. The Inter-American Commission on
Human Rights has also reiterated its position regarding “the impact of
such sanctions on the human rights of the Cuban people and, therefore,
INSISTS THAT THE EMBARGO BE LIFTED.”

[Follow-up: In November 2009, with the exceptions of only the USA,
Israel and a handful of tiny, US island-colonies in the South Pacific,
representatives of EVERY nation on the planet voted at the UN General
Assembly to condemn these cruel and inhumane sanctions.]

"[E]xports of food and agricultural products to Cuba remain regulated
by the Department of Commerce and require a licence for export or re-
export. The export of medicines and medical supplies continues to be
SEVERELY LIMITED....

“The RESTRICTIONS IMPOSED BY THE EMBARGO help to deprive Cuba of vital
access to medicines, new scientific and medical technology, food,
chemical water treatment and electricity.”

"The provision of health care has suffered from the LIMITATIONS AND
RESTRICTIONS IMPOSED BY THE EMBARGO on the procurement of basic and
specialized medical equipment and chemical components needed for the
production of generic medicines....

"Cuba was UNABLE TO IMPORT nutritional products destined for children
and for consumption at schools, hospitals and day care centres. This
had an adverse effect on the health and nutritional status of the
population.

"Children’s health was also put at risk by a decision from syringe
suppliers to CANCEL an order for 3 million disposable syringes by
UNICEF’s Global Alliance for Vaccines and Immunization when it became
known that the units were destined for the implementation of the
programme in Cuba.

"The number of children suffering from heart conditions who are
waiting for appropriate treatment at a pediatric hospital has
increased after Cuba was unable to buy from the US-based companies the
necessary medical equipment for their treatment. The companies
allegedly refused to negotiate with Cuba because of the RESTRICTIONS
SET BY THE US EMBARGO.

"LACK OF ACCESS to products manufactured by United States companies
such as St. Jude Medical, Boston Scientific and Amplatzer prevents the
provision of proper care to seriously ill patients who need a
pacemaker, St. Jude prosthetic valves or septal occluders, forcing
their treatment with alternative, riskier surgical techniques.

"It has been IMPOSSIBLE TO PURCHASE a positron emission tomography/
computerized tomography (PET/CT) scanner, a state-of-the-art piece of
medical equipment needed for treatment that is made by only three
manufacturers worldwide, all unauthorized to negotiate with Cuba."

The impact of economic sanctions on health and health services is not
limited to difficulties in the supply of medicine. Health and health
services depend on functioning water and sanitation infrastructure, on
electricity and other functioning equipment such as X-ray facilities
or refrigerators to store vaccines. The financial burden and
commercial barriers have led to shortages or intermittent availability
of drugs, medicines, equipment and spare parts. It has also hindered
the renovation of hospitals, clinics and care centres for the elderly.

http://www.amnesty.org/en/library/asset/AMR25/007/2009/en/540b61a6-d0ec-493b-84c4-372a0b3c5067/amr250072...

http://www.amnesty.org/en/library/asset/AMR25/007/2009/en/51469f8b-73f8-47a2-a5bd-f839adf50488/amr250072...
(PDF format)

Note that Article 2c of the UN Genocide Convention states that the
crime of genocide includes, among other things, "deliberately
inflicting on the group conditions of life calculated to bring about
its physical destruction in whole or in part."

http://www2.ohchr.org/english/law/ge...

Again, as Amnesty International has reported, “The restrictions
imposed by the embargo help to deprive Cuba of vital access to
medicines, new scientific and medical technology, food, chemical water
treatment and electricity.” These are deliberate acts, the only
purpose of which can be to bring about the physical destruction of the
Cuban people in whole or in part. These cruel sanctions can,
therefore, even be seen as a form of genocide under international law!
Makes you proud, don't it, America?

Contrary to PL's self-serving lies and rationalizations, no amount of
US exports (or anything else) can possibly let his political masters
off the hook for deliberately depriving Cubans of "vital access to
medicines, new scientific and medical technology, food, chemical water
treatment and electricity.” This is genocide, pure and simple.

PL

7/2/2010 11:09:00 AM

0

Amnesty blasts Cuba's rights record

A report from human rights group Amnesty International has accused Cuba
of instituting "a climate of fear that stifles and criminalises dissent"
against the island's communist government.

According to the report, which was released on Wednesday, Cuban laws are
so vague and arbitrary that any act of dissent can be deemed criminal.

The Cuban government has not issued an official response to the report,
but it routinely dismisses international human rights groups as tools of
the United States.

Amnesty has said it gathered information from independent sources on and
off the island, but conducted no first-hand research because it has been
banned from Cuba since 1990.

The report said that although Cuba signed the International Covenant on
Civil and Political Rights in February 2008, there has been no
improvement in rights for Cuban citizens.

It noted also that independent Cuban journalists continue to face a wide
range of restrictions and repression while attempting to report in
defiance of state controls on all media.

"There is certainly a wave, we would call it, of harassment and
arbitrary detention of independent journalists at the moment,'' Kerrie
Howard, Amnesty International's deputy director for the Americas, told
the Associated Press in the Spanish capital Madrid where the report was
released.

According to Amnesty, the Cuban government has launched crackdowns on
individual liberties in the name of national security and in response to
Washington's 48-year-old trade sanctions against the country.

'Lame excuse'
Guillermo Farinas, another activist, went on a hunger strike following
Tamayo's death [EPA]

"No matter how detrimental its impact, the US embargo is a lame excuse
for violating the rights of citizens, as it can in no way diminish the
obligation on the Cuban government to protect, respect and fulfil the
human rights of all Cubans,'' the report said.

Cuba's human rights situation has been in the spotlight since the death
of dissident Orlando Zapata Tamayo in February after a long hunger
strike behind bars.

Tamayo had been designated as a "prisoner of conscience" by Amnesty.

Guillermo Farinas, another opposition activist, has refused to eat or
drink since then, although he has received fluids and nutrients
intravenously at a hospital near his home in central Cuba.

The Cuban government insists that it holds no political prisoners and
safeguards human rights by providing citizens with free education and
health care, as well as heavily subsidised housing, utilities,
transportation and food.

http://english.aljazeera.net/news/americas/2010/07/201071153564...