4
我想弄清楚如何用Rails 4制作应用程序。我一直在基本的东西上停滞不前,而且我似乎无法确定使用未来的原则。如何定义链接路径
我有一个配置文件模型和一个行业模型。该协会是:
简介:
has_and_belongs_to_many :industries, join_table: 'industries_profiles'
行业:
has_and_belongs_to_many :profiles, join_table: 'industries_profiles'
在我的个人资料显示页面,我现在正在尝试链接到网页行业:
<% @profile.industries.limit(5).each do |industry| %>
<%= link_to industry.sector.upcase, industry_path(@industry) %>
<% end %>
我找不到适用于此链接的任何内容。
我曾尝试以下:
industry_path(@profile.industry)
industry_path(@profile.industry_id)
industry_path(industry)
industry_path(profile.industry)
industry_path(industry.id)
industry_path(industry_id)
但是所有的人都猜测。我不知道如何准备API码头,因此我无法理解它的任何内容。
任何人都可以看到如何链接到单个记录的HABTM协会的另一侧的显示页面?
你有什么你的routes.rb文件? 'industry_path(行业)'是你应该使用的一个。 –
我有:资源:行业 – Mel
当我尝试的时候,当我将鼠标悬停在链接上时,它显示了一个具有正确行业ID的路径。但我不能点击它 - 没有任何反应 – Mel