This way we fix a bug we mentioned in commit 930bb753c which caused
links to documents to be broken when editing their title because the
title was used to generate the URL of the document.
Note we're still using Paperclip to render cached attachments because
this is the only case where we store files with just Paperclip and not
Active Storage.
With Active Storage, we render attachments just like any other resource,
using `polymorphic_path`. Paperclip included the `url` method in the
model; since the model doesn't have access to the request parameters
(like the host), this was inconvenient because it wasn't possible to
generate absolute URLs with Paperclip.
In order to simplify the code and make it similar to the way we used
Paperclip, we're adding a `variant` method accepting the name of a
variant and returning the variant.
34 lines
1.4 KiB
Plaintext
34 lines
1.4 KiB
Plaintext
<div id="<%= dom_id(investment) %>" class="investments-list-item">
|
|
<% if investment.image.present? %>
|
|
<%= image_tag investment.image.variant(:large), alt: investment.image.title.unicode_normalize %>
|
|
<% else %>
|
|
<%= image_tag "budget_investment_no_image.jpg", alt: investment.title %>
|
|
<% end %>
|
|
|
|
<% if investment.should_show_vote_count? || investment.should_show_price? %>
|
|
<div class="supports-and-price">
|
|
<% if investment.should_show_vote_count? %>
|
|
<span class="supports-title"><%= t("budgets.investments_list.investment.supports") %></span>
|
|
<strong><%= investment.total_votes %></strong>
|
|
<% end %>
|
|
|
|
<% if investment.should_show_price? %>
|
|
<span class="price-title"><%= t("budgets.investments_list.investment.price") %></span>
|
|
<strong><%= investment.formatted_price %></strong>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="budget-investment-content">
|
|
<% cache [locale_and_user_status(investment), "index", investment, investment.author] do %>
|
|
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
|
|
|
<%= render Budgets::Investments::InfoComponent.new(investment) %>
|
|
|
|
<%= link_to namespaced_budget_investment_path(investment), class: "read-more" do %>
|
|
<small><%= t("budgets.investments_list.investment.read_more") %></small>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|