Budget::Investment::Milestone is imageable
Admin form attaches an image Milestone list has a column "Image", empty or with a link to the image
This commit is contained in:
@@ -40,7 +40,8 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
|
||||
|
||||
def milestone_params
|
||||
params.require(:budget_investment_milestone)
|
||||
.permit(:title, :description, :budget_investment_id)
|
||||
.permit(:title, :description, :budget_investment_id,
|
||||
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
|
||||
end
|
||||
|
||||
def load_budget_investment
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class Budget
|
||||
class Investment
|
||||
class Milestone < ActiveRecord::Base
|
||||
include Imageable
|
||||
|
||||
belongs_to :investment
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<%= f.text_field :title, maxlength: Budget::Investment::Milestone.title_max_length %>
|
||||
<%= f.text_area :description, rows: 5 %>
|
||||
<%= render 'images/admin_image', imageable: @milestone, f: f %>
|
||||
|
||||
<%= f.submit nil, class: "button success" %>
|
||||
<% end %>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<th><%= t("admin.milestones.index.table_id") %></th>
|
||||
<th><%= t("admin.milestones.index.table_title") %></th>
|
||||
<th><%= t("admin.milestones.index.table_description") %></th>
|
||||
<th><%= t("admin.milestones.index.image") %></th>
|
||||
<th><%= t("admin.milestones.index.table_actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -20,6 +21,9 @@
|
||||
<td class="small">
|
||||
<%= milestone.description %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= link_to 'Ver imagen', milestone.image_url(:large), target: :_blank if milestone.image.present? %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone),
|
||||
method: :delete,
|
||||
|
||||
Reference in New Issue
Block a user