ruby-on-railsrubysqueel

in `lambda': tried to create Proc object without a block (ArgumentError)


scope :for_user, (lambda {|user_id| a = Follow.follows(user_id); Question.where{user_id.in(a.select{followed_id})}})

Gives me:

`lambda': tried to create Proc object without a block (ArgumentError)

I've read several questions without being able to fix the problem. I am relatively new to Ruby, and just getting started with Rails. I'm probably a bit over my head.


Solution

  • I don't think you need the () around the lambda, though. How about you try building up from simple fist eg try:

    scope :for_user, lambda {|user_id| Question.where(:user_id => user_id) }
    

    just to see if it breaks/works... then add your actually-required functionality piece by piece until something breaks (or it all works)