use a more DRY way to build project view
This commit is contained in:
@@ -2,4 +2,8 @@ module ProjectsHelper
|
|||||||
def project_form_fields
|
def project_form_fields
|
||||||
[:name, :email, :short_name, :offer_date, :order_date]
|
[:name, :email, :short_name, :offer_date, :order_date]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def project_view_fields
|
||||||
|
[:name, :email, :short_name, :offer_date, :order_date]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
<div id="<%= dom_id project %>">
|
<div id="<%= dom_id project %>">
|
||||||
|
<% project_view_fields.each do |attrib| %>
|
||||||
<p>
|
<p>
|
||||||
<strong>Name:</strong>
|
<strong><%= attrib.to_s.humanize %>:</strong>
|
||||||
<%= project.email %> <%= project.name %>
|
<%= value = project.send(attrib) %>
|
||||||
|
<%= value.is_a?(Date) ? l(value) : value %>
|
||||||
</p>
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if project.subprojects.any? %>
|
<% if project.subprojects.any? %>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
resources :clients
|
resources :clients
|
||||||
resources :subprojects
|
resources :subprojects
|
||||||
resources :subprojects
|
|
||||||
resources :subproject_addresses
|
resources :subproject_addresses
|
||||||
resources :projects
|
resources :projects
|
||||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||||
|
|||||||
Reference in New Issue
Block a user