diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb index 60b686f0..5b871bd9 100644 --- a/app/controllers/desktop/co_authors_controller.rb +++ b/app/controllers/desktop/co_authors_controller.rb @@ -18,6 +18,7 @@ class Desktop::CoAuthorsController < ApplicationController def new @co_author = CoAuthor.new + @co_author_relations = CoAuthorRelation.all respond_to do |format| format.html { render :layout => false} diff --git a/app/models/user/co_author.rb b/app/models/user/co_author.rb index 51aefdc3..9bcaf7d6 100644 --- a/app/models/user/co_author.rb +++ b/app/models/user/co_author.rb @@ -13,7 +13,7 @@ class CoAuthor VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/ validates :email, format: { with: VALID_EMAIL_REGEX }, allow_blank: true, - uniqueness: { case_sensitive: false } + uniqueness: { case_sensitive: false } validates :co_author, presence: true before_save { |coauthor| coauthor.email = email.downcase if not coauthor.email.nil?} diff --git a/app/models/user/co_author_relation.rb b/app/models/user/co_author_relation.rb index 22345ff3..b4fb40ea 100644 --- a/app/models/user/co_author_relation.rb +++ b/app/models/user/co_author_relation.rb @@ -5,4 +5,6 @@ class CoAuthorRelation field :relation, localize: true has_and_belongs_to_many :co_authors + + validates :relation, presence: true end diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 100f851f..42254d10 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -3,7 +3,7 @@ class User include Mongoid::Document include Mongoid::Timestamps - devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :timeoutable + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :validatable, :timeoutable mount_uploader :avatar, AvatarUploader @@ -194,4 +194,4 @@ class User end end -end \ No newline at end of file +end diff --git a/app/views/desktop/co_authors/_form.html.erb b/app/views/desktop/co_authors/_form.html.erb index e5d9e8ff..4f57b9ca 100644 --- a/app/views/desktop/co_authors/_form.html.erb +++ b/app/views/desktop/co_authors/_form.html.erb @@ -15,19 +15,14 @@ <%= f.text_field :email %> -