2010-12-05 6 views

答えて

0

current_user.courses.size > 0

0

1でも短い:

redirect_to(root_url) if @user.courses.size.zero? 
0

あるいは短いために行くだろう:

def require_course 
    redirect_to root_url if @user.courses.empty? 
end 

root_urlでの点に注意してください。 root_pathの代わりに、hereと記載されている。