1
컨트롤러 대신 모델에 논리를 넣고 싶습니다.레일에있는 컨트롤러에서 모델의 메서드에 액세스하는 방법
class UsersController < ApplicationController
def somemethod
d = User.methodinmodel
end
end
class User < ActiveRecord::Base
def methodinmodel
"retuns foo"
end
end
은 내가 User
모델에 대한 methodinmodel
가 없다는 오류가 발생합니다.
왜? 오히려 특정 사용자보다 일반적으로 User
클래스에 methodinmodel
를 호출 할 수있게하려면