开发者

Displaying links on columns mapped to custom attributes

开发者 https://www.devze.com 2022-12-08 03:04 出处:网络
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

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 %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号