get '/:nickname/feed' do
user = User.first(:nickname => params[:nickname])
if user
else
not_found 'unknown user'
end
end
On Friday, January 18, 2013 12:55:25 PM UTC-6, Alex wrote:
Hi,I have a problem getting the user’s name property. What am I doing wrong? I’m going insane why it’s not getting the name:
NoMethodError at /sican/feed
undefined method `name' for #<Enumerator: User:find("sican")>
Here’s the get method (commented out are some other alternatives that I’ve tried):
get '/:nickname/feed' do
@user_name = User.find(params[:nickname]).name
#user = User.get(params[:nickname])
#@user_name = user.name
end
Here’s the User class:
class User
include DataMapper::Resource
property :id, Serial
property :uid, String
property :name, String
property :nickname, String
property :created_on, DateTime
has n, :posts
end
Any ideas?