diff --git a/app/models/garden.rb b/app/models/garden.rb index 0514f2a96..15bbaa9de 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -28,10 +28,14 @@ class Garden < ActiveRecord::Base scope :active, -> { where(:active => true) } scope :inactive, -> { where(:active => false) } + validates :location, + :length => { :maximum => 255 } + validates :name, :format => { :with => /\S/ - } + }, + :length => { :maximum => 255 } validates :area, :numericality => { diff --git a/app/models/notification.rb b/app/models/notification.rb index 3825d7b12..01f157df9 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -3,6 +3,8 @@ class Notification < ActiveRecord::Base belongs_to :recipient, :class_name => 'Member' belongs_to :post + validates :subject, :length => { :maximum => 255 } + default_scope { order('created_at DESC') } scope :unread, -> { where(:read => false) } diff --git a/app/models/post.rb b/app/models/post.rb index 3a1b372af..6aaf8b72d 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -41,7 +41,9 @@ class Post < ActiveRecord::Base validates :subject, :format => { :with => /\S/ - } + }, + :length => { :maximum => 255 } + def author_date_subject # slugs are created before created_at is set diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 09c3b99ef..74b33249d 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -11,7 +11,7 @@ .form-group.required = f.label :name, :class => 'control-label col-md-2' .col-md-8 - = f.text_field :name, :class => 'form-control' + = f.text_field :name, :class => 'form-control', :maxlength => 255, :required => "required" .form-group = f.label :description, :class => 'control-label col-md-2' @@ -21,7 +21,7 @@ .form-group = f.label :location, :class => 'control-label col-md-2' .col-md-8 - = f.text_field :location, :value => @garden.location || current_member.location, :class => 'form-control', :placeholder => 'optional' + = f.text_field :location, :value => @garden.location || current_member.location, :class => 'form-control', :placeholder => 'optional', :maxlength => 255 %span.help-block If you have a location set in your profile, it will be used when you create a new garden. diff --git a/app/views/notifications/_form.html.haml b/app/views/notifications/_form.html.haml index 6e73c7444..094be410d 100644 --- a/app/views/notifications/_form.html.haml +++ b/app/views/notifications/_form.html.haml @@ -13,7 +13,7 @@ To: = link_to @recipient, @recipient = label_tag :notification, "Subject:" - = f.text_field :subject, :value => @subject, :class => 'form-control' + = f.text_field :subject, :value => @subject, :class => 'form-control', :maxlength => 255 = label_tag :body, "Type your message here:" = f.text_area :body, :rows => 12, :class => 'form-control' %span.help-block diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index 1ef7efb51..607b76bd8 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -8,7 +8,7 @@ .form-group = label_tag :post, "Subject", :class => 'control-label' - = f.text_field :subject, :class => 'form-control', :autofocus => 'autofocus' + = f.text_field :subject, :class => 'form-control', :autofocus => 'autofocus', :maxlength => 255 .form-group - if @post.forum || @forum