Use local variables in group and heading partials
We usually prefer local variables over instance variables in partials. This way we'll be able to call the partial from views or components where the instance variable isn't available. And since we're using the `path` variable to configure the URL, we don't have to specify extra variables like `@budget` or the namespace `:admin` in `form_for`, since Rails only uses those variables to set the URL.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<%= render "shared/globalize_locales", resource: @group %>
|
||||
<%= render "shared/globalize_locales", resource: group %>
|
||||
|
||||
<%= translatable_form_for [:admin, @budget, @group], url: path do |f| %>
|
||||
<%= translatable_form_for group, url: path do |f| %>
|
||||
|
||||
<%= render "shared/errors", resource: @group %>
|
||||
<%= render "shared/errors", resource: group %>
|
||||
|
||||
<div class="row">
|
||||
<%= f.translatable_fields do |translations_form| %>
|
||||
@@ -12,11 +12,11 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if @group.persisted? %>
|
||||
<% if group.persisted? %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= f.select :max_votable_headings,
|
||||
(1..@group.headings.count),
|
||||
(1..group.headings.count),
|
||||
hint: t("admin.budget_groups.form.max_votable_headings_info") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<%= render "header", action: "edit" %>
|
||||
|
||||
<%= render "form", path: admin_budget_group_path(@budget, @group), action: "submit" %>
|
||||
<%= render "form", group: @group, path: admin_budget_group_path(@budget, @group), action: "submit" %>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<%= render "header", action: "create" %>
|
||||
|
||||
<%= render "form", path: admin_budget_groups_path(@budget), action: "create" %>
|
||||
<%= render "form", group: @group, path: admin_budget_groups_path(@budget), action: "create" %>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<%= render "shared/globalize_locales", resource: @heading %>
|
||||
<%= render "shared/globalize_locales", resource: heading %>
|
||||
|
||||
<%= translatable_form_for [:admin, @budget, @group, @heading], url: path do |f| %>
|
||||
<%= translatable_form_for heading, url: path do |f| %>
|
||||
|
||||
<%= render "shared/errors", resource: @heading %>
|
||||
<%= render "shared/errors", resource: heading %>
|
||||
|
||||
<div class="row">
|
||||
<%= f.translatable_fields do |translations_form| %>
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= f.text_field :price, maxlength: 8 %>
|
||||
|
||||
<% if @heading.budget.approval_voting? %>
|
||||
<% if heading.budget.approval_voting? %>
|
||||
<%= f.number_field :max_ballot_lines,
|
||||
hint: t("admin.budget_headings.form.max_ballot_lines_info") %>
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<%= render "header", action: "edit" %>
|
||||
|
||||
<%= render "form", path: admin_budget_group_heading_path(@budget, @group, @heading), action: "submit" %>
|
||||
<%= render "form", heading: @heading, path: admin_budget_group_heading_path(@budget, @group, @heading), action: "submit" %>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<%= render "header", action: "create" %>
|
||||
|
||||
<%= render "form", path: admin_budget_group_headings_path(@budget, @group), action: "create" %>
|
||||
<%= render "form", heading: @heading, path: admin_budget_group_headings_path(@budget, @group), action: "create" %>
|
||||
|
||||
Reference in New Issue
Block a user