[Facebooker-talk] view problem
kevin lochner
klochner at gmail.com
Fri Jan 23 17:40:20 EST 2009
I was wrong, it's not just in the view, it's a problem in the
controller as well.
This may be considered a bug - if the user location is empty, the
object returned by user.location is a string,
so calling user.location.city throws an exception.
In my controller I iterate over users with the following:
> friends.each do |f|
> logger.warn "class: #{f.current_location.class}"
> logger.warn "location: #{f.current_location}"
> if f.current_location
logger.warn "city: #{f.current_location.city} \n"
> end
> end
and I get the following output:
>class: Facebooker::Location
>location: #<Facebooker::Location:0x7fe614b68eb8>
>city:
>class: Facebooker::Location
>location: #<Facebooker::Location:0x7fe614b67b58>
>city: Ann Arbor
>class: String
>location:
> NoMethodError (undefined method `city' for "":String):
and for verification i dumped the hash from which the user was
populated:
> nameJeff
SmithuidXXXXXlocaleen_USfirst_nameJeffcurrent_locationlast_nameSmith
On Jan 23, 2009, at 5:26 PM, Mike Mangino wrote:
> user.location is returning an object, so when to_s is called you get
> the inspect string, like #<Location 34327832>
>
> user.location.city should print the string.
>
> Mike
>
> On Jan 23, 2009, at 4:36 PM, kevin lochner wrote:
>
>> i'm trying to print out user locations in my view. I'd like to
>> just pass a user model to the
>> view and print out the user location as user.location.city
>>
>> I can access user.location.city in the controller, but in the view
>> user.location returns "#"
>>
>> Could someone explain what's going on and maybe give an alternative
>> solution?
>>
>> _______________________________________________
>> Facebooker-talk mailing list
>> Facebooker-talk at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>
> --
> Mike Mangino
> http://www.elevatedrails.com
>
>
>
More information about the Facebooker-talk
mailing list