diff --git a/app/models/chapter.rb b/app/models/chapter.rb index 3a0f0a47..0317edf6 100644 --- a/app/models/chapter.rb +++ b/app/models/chapter.rb @@ -25,6 +25,8 @@ class Chapter < ApplicationRecord validates_presence_of :slug validates_uniqueness_of :name + validates :name, :slug, :twitter_url, :facebook_url, :instagram_url, :email_address, :blog_url, :rss_feed_url, :extra_question_1, :extra_question_2, :extra_question_3, length: {maximum: 255} + validates_format_of :slug, :with => /\A[a-z0-9-]+\Z/ def self.any_chapter diff --git a/app/views/chapters/_form.html.erb b/app/views/chapters/_form.html.erb index 51ea968e..f68429b6 100644 --- a/app/views/chapters/_form.html.erb +++ b/app/views/chapters/_form.html.erb @@ -1,33 +1,33 @@ <%= simple_form_for chapter do |form| -%> <% if current_user.can_create_chapters? %>
- <%= form.input :inactive, :as => :boolean %> + <%= form.input :inactive, as: :boolean %>
<% end %> - <%= form.input :name %> - <%= form.input :slug %> - <%= form.input :twitter_url %> - <%= form.input :facebook_url %> - <%= form.input :instagram_url %> - <%= form.input :email_address %> - <%= form.input :blog_url %> - <%= form.input :rss_feed_url %> + <%= form.input :name, maxlength: true %> + <%= form.input :slug, maxlength: true %> + <%= form.input :twitter_url, maxlength: true %> + <%= form.input :facebook_url, maxlength: true %> + <%= form.input :instagram_url, maxlength: true %> + <%= form.input :email_address, maxlength: true %> + <%= form.input :blog_url, maxlength: true %> + <%= form.input :rss_feed_url, maxlength: true %> <%= form.input :description %> <%= form.input :hide_trustees %> <%= form.input :country do %> <% form.select :country, CountryOptions.countries_for_select(include_blank: true, selected: form.object.country) %> <% end %> <%= form.input :time_zone %> - <%= form.input :locale, :collection => I18n.available_locales, :include_blank => false, :label => t('simple_form.labels.chapter.locale', :slug => chapter.slug) %> + <%= form.input :locale, collection: I18n.available_locales, include_blank: false, label: t('simple_form.labels.chapter.locale', slug: chapter.slug) %>
<%= form.input :application_intro, maxlength: 1000 %> - <%= form.input :extra_question_1 %> - <%= form.input :extra_question_2 %> - <%= form.input :extra_question_3 %> - <%= form.input :submission_response_email, :input_html => { :placeholder => Chapter::DEFAULT_SUBMISSION_RESPONSE_EMAIL } %> + <%= form.input :extra_question_1, maxlength: true %> + <%= form.input :extra_question_2, maxlength: true %> + <%= form.input :extra_question_3, maxlength: true %> + <%= form.input :submission_response_email, input_html: {placeholder: Chapter::DEFAULT_SUBMISSION_RESPONSE_EMAIL} %> <%= form.button :submit %> <% end -%>