Merge pull request #859 from CloCkWeRX/add_title_validations

Add title validations
This commit is contained in:
Cesy
2016-04-03 11:45:10 +01:00
6 changed files with 14 additions and 6 deletions

View File

@@ -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 => {

View File

@@ -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) }

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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