Displaying links on columns mapped to custom attributes
Say I have Course that has_many Students. I also have de开发者_StackOverflow社区f top_student in the Course class. I now have an active_scaffold on top of Course, but if I add top_student as a column it show shows #, but no link. I'd like a link to the Student who is the Top Student. Any way to make this happen?
class Course < ActiveRecord::Base
# Class method
def self.top_student
# Some logic
end
end
it should be:
<%=link_to "Top Student", Course.top_student %>
精彩评论