[DataMapper] Re: cannot get property value from User class

2013-01-18 Thread Abe Voelker
Give this a try:

get '/:nickname/feed' do
  user = User.first(:nickname = params[:nickname])
  if user
@user_name = user.name
  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? 


-- 
You received this message because you are subscribed to the Google Groups 
DataMapper group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/CGPpRzvNH9gJ.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.



[DataMapper] Re: cannot get property value from User class

2013-01-18 Thread Alex
Thanks Abe, works great!

-- 
You received this message because you are subscribed to the Google Groups 
DataMapper group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/05B2ZIb4T3UJ.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.