Adds phases to form

This commit is contained in:
kikito
2017-01-01 15:03:58 +01:00
parent ecb3461a97
commit 9e4b2fda89
3 changed files with 10 additions and 2 deletions

View File

@@ -40,7 +40,9 @@ class Admin::BudgetsController < Admin::BaseController
private
def budget_params
params.require(:budget).permit(:name, :description, :phase, :currency_symbol)
descriptions = Budget::PHASES.map{|p| "description_#{p}"}.map(&:to_sym)
valid_attributes = [:name, :phase, :currency_symbol] + descriptions
params.require(:budget).permit(*valid_attributes)
end
end

View File

@@ -31,6 +31,10 @@ class Budget < ActiveRecord::Base
self.send("description_#{self.phase}").try(:html_safe)
end
def self.description_max_length
2000
end
def accepting?
phase == "accepting"
end

View File

@@ -2,7 +2,9 @@
<%= f.text_field :name, maxlength: Budget.title_max_length %>
<%= f.cktext_area :description, maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %>
<% Budget::PHASES.each do |phase| %>
<%= f.cktext_area "description_#{phase}", maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %>
<% end %>
<div class="row">
<div class="small-12 medium-9 column">