[rails][actionview]

ActionView

分析 link_to 动态生成链接的功能,主要工作在 url_for 这个方法

link_to "Profile", @profile
# => <a href="/profiles/1">Profile</a>
  • link_to, url_for
    • rails/actionview/lib/action_view/helpers/url_helper.rb
    • rails/actionview/lib/action_view/routing_url_for.rb
      • builder = ActionDispatch::Routing::PolymorphicRoutes::HelperMethodBuilder.send(method)
    • rails/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
      • model.model_name.singular_route_key

你可能感兴趣的:([rails][actionview])