Hi,
I have the following code fragment;
@comm_type = Communication.find_by_sql('select id from
communication_types where upper(description) = "EMAIL"')
Which results in
>> @comm_type
=> [#<Communication:0x39a0f60
@attributes={"id"=>"4"}>]
But when I try to test an ActiveREcord against this it doesn't work;
@recipient.communications.each do |comm|
if comm.communications_type_id == @comm_type
@email_address = comm.code
end
end
What do I need to write to get at that value in the hash. Sorry it's
such a dumb question :~(
Cheers,
Eric.
On Jan 31, 2006, at 3:51 PM, Eric Sloane wrote:
> Hi,
> I have the following code fragment;
>
> @comm_type = Communication.find_by_sql('select id from
> communication_types where upper(description) = "EMAIL"')
>
> Which results in
> >> @comm_type
> => [#<Communication:0x39a0f60
@attributes={"id"=>"4"}>]
>
> But when I try to test an ActiveREcord against this it doesn't work;
>
> @recipient.communications.each do |comm|
> if comm.communications_type_id == @comm_type
if comm.communications_type_id == @comm_type.id
> @email_address = comm.code
> end
> end
>
> What do I need to write to get at that value in the hash. Sorry
> it's such a dumb question :~(
>
> Cheers,
> Eric.
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
I think thats all your missing
Cheers-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
Hi Ezra,
Nope - I tried that (and a few other combinations) @comm_type.id is
returning the id of the hash not the id within the hash. I'd have
expected to get the attribute 4 too, but noooo
Eric.
Ezra Zygmuntowicz wrote:
>
> On Jan 31, 2006, at 3:51 PM, Eric Sloane wrote:
>
>> Hi,
>> I have the following code fragment;
>>
>> @comm_type = Communication.find_by_sql('select id from
>> communication_types where upper(description) = "EMAIL"')
>>
>> Which results in
>> >> @comm_type
>> => [#<Communication:0x39a0f60
@attributes={"id"=>"4"}>]
>>
>> But when I try to test an ActiveREcord against this it doesn't work;
>>
>> @recipient.communications.each do |comm|
>> if comm.communications_type_id == @comm_type
>
> if comm.communications_type_id == @comm_type.id
>
>> @email_address = comm.code
>> end
>> end
>>
>> What do I need to write to get at that value in the hash. Sorry it's
>> such a dumb question :~(
>>
>> Cheers,
>> Eric.
>>
>> _______________________________________________
>> Rails mailing list
>> Rails@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
> I think thats all your missing
>
> Cheers-
> -Ezra Zygmuntowicz
> Yakima Herald-Republic
> WebMaster
> http://yakimaherald.com
> 509-577-7732
> ezra@yakima-herald.com
Eric-
Ahh your right. Ok well this will work:
@comm_type[0][:id]
Cheers-
-Ezra
On Jan 31, 2006, at 4:09 PM, Eric Sloane wrote:
> Hi Ezra,
> Nope - I tried that (and a few other combinations) @comm_type.id is
> returning the id of the hash not the id within the hash. I'd have
> expected to get the attribute 4 too, but noooo
> Eric.
>
> Ezra Zygmuntowicz wrote:
>> On Jan 31, 2006, at 3:51 PM, Eric Sloane wrote:
>>> Hi,
>>> I have the following code fragment;
>>>
>>> @comm_type = Communication.find_by_sql('select id from
>>> communication_types where upper(description) = "EMAIL"')
>>>
>>> Which results in
>>> >> @comm_type
>>> => [#<Communication:0x39a0f60
@attributes={"id"=>"4"}>]
>>>
>>> But when I try to test an ActiveREcord against this it doesn't
work;
>>>
>>> @recipient.communications.each do |comm|
>>> if comm.communications_type_id == @comm_type
>> if comm.communications_type_id == @comm_type.id
>>> @email_address = comm.code
>>> end
>>> end
>>>
>>> What do I need to write to get at that value in the hash. Sorry
>>> it's such a dumb question :~(
>>>
>>> Cheers,
>>> Eric.
>>>
>>> _______________________________________________
>>> Rails mailing list
>>> Rails@lists.rubyonrails.org
>>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>>
>> I think thats all your missing
>> Cheers-
>> -Ezra Zygmuntowicz
>> Yakima Herald-Republic
>> WebMaster
>> http://yakimaherald.com
>> 509-577-7732
>> ezra@yakima-herald.com
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
Hi Ezra - Many Thanks. Works just like a bought one!!
Eric.
Ezra Zygmuntowicz wrote:
> Eric-
>
> Ahh your right. Ok well this will work:
>
> @comm_type[0][:id]
>
> Cheers-
> -Ezra
>
> On Jan 31, 2006, at 4:09 PM, Eric Sloane wrote:
>
>> Hi Ezra,
>> Nope - I tried that (and a few other combinations) @comm_type.id is
>> returning the id of the hash not the id within the hash. I'd have
>> expected to get the attribute 4 too, but noooo
>> Eric.
>>
>> Ezra Zygmuntowicz wrote:
>>
>>> On Jan 31, 2006, at 3:51 PM, Eric Sloane wrote:
>>>
>>>> Hi,
>>>> I have the following code fragment;
>>>>
>>>> @comm_type = Communication.find_by_sql('select id from
>>>> communication_types where upper(description) =
"EMAIL"')
>>>>
>>>> Which results in
>>>> >> @comm_type
>>>> => [#<Communication:0x39a0f60
@attributes={"id"=>"4"}>]
>>>>
>>>> But when I try to test an ActiveREcord against this it doesn't
work;
>>>>
>>>> @recipient.communications.each do |comm|
>>>> if comm.communications_type_id == @comm_type
>>>
>>> if comm.communications_type_id == @comm_type.id
>>>
>>>> @email_address = comm.code
>>>> end
>>>> end
>>>>
>>>> What do I need to write to get at that value in the hash. Sorry
>>>> it's such a dumb question :~(
>>>>
>>>> Cheers,
>>>> Eric.
>>>>
>>>> _______________________________________________
>>>> Rails mailing list
>>>> Rails@lists.rubyonrails.org
>>>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>>>
>>> I think thats all your missing
>>> Cheers-
>>> -Ezra Zygmuntowicz
>>> Yakima Herald-Republic
>>> WebMaster
>>> http://yakimaherald.com
>>> 509-577-7732
>>> ezra@yakima-herald.com
>>
>>
>> _______________________________________________
>> Rails mailing list
>> Rails@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
> -Ezra Zygmuntowicz
> Yakima Herald-Republic
> WebMaster
> http://yakimaherald.com
> 509-577-7732
> ezra@yakima-herald.com