xyzt
October 29, 2007, 2:33pm
1
hello,
I have a boolean field(is_suit) in a table(I use mysql) and I have Room
class for this table.I compare the room entity lie this:
<%if room.is_suit? then%>
<%=image_tag(’/images/icon/suit.jpg’) %>
<%end%>
but it shows the image for all the records not just for is_suit=b’1’ but
also is_suit=b’0’.
where’s the wrong?
thanks.
xyzt
October 29, 2007, 2:35pm
2
Hi,
Bahadır Doğan wrote:
I have a boolean field(is_suit) in a table(I use mysql) and I have Room
class for this table.
Could you post the migration that generated this field and the DDL
(“explain rooms”) that resulted from it?
Lutz
xyzt
October 29, 2007, 2:37pm
3
Lutz H. wrote:
Hi,
Bahadır Doğan wrote:
I have a boolean field(is_suit) in a table(I use mysql) and I have Room
class for this table.
Could you post the migration that generated this field and the DDL
(“explain rooms”) that resulted from it?
Lutz
CREATE TABLE msf
.rooms
(
id
int(10) unsigned NOT NULL auto_increment,
odano
int(10) unsigned NOT NULL,
tekyatak
int(10) unsigned NOT NULL,
ciftyatak
int(10) unsigned NOT NULL,
kat
int(10) unsigned NOT NULL,
is_suit
bit(1) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
xyzt
October 29, 2007, 2:54pm
4
Him
Bahadır Doğan wrote:
is_suit
bit(1) NOT NULL,
The possible values of this field are b’1’ and b’0’ for true and false.
On the RoR site, these are represented as “\001” and “\000” which are
both true .
If you generate a boolean field using a migration
t.column :is_suit, :boolean
a column with the MySQL type tinyint(1) is created. For this column,
is_suit? works.
Lutz
xyzt
October 29, 2007, 3:05pm
5
thanks.that solved the problem.