我有一個方法,在我的模型,如何調用索引之前的方法和新的模式
def self.interests(user)
City.joins("INNER JOIN property_of_interests ON property_of_interests.city_id = cities.id").where(:property_of_interests => {:user_id => user})
end
我想調用這個方法進入指數和新的行動之前,我的控制器,我怎麼能我能做到這一點?
而且所有的模型和控制器是不同的實體
如果我在控制器中使用的before_filter我將如何傳遞CURRENT_USER參數的方法嗎?
你能更好地解釋你想做的事,好嗎? –
也許使用'before_filter'(http://rails-bestpractices.com/posts/22-use-before_filter) – lurker
但我想將current_user參數傳遞給方法 –