diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/answer.rb | 1 | ||||
-rw-r--r-- | app/models/question.rb | 3 | ||||
-rw-r--r-- | app/models/question_category.rb | 1 | ||||
-rw-r--r-- | app/models/question_content_multiple_choice.rb | 9 | ||||
-rw-r--r-- | app/models/question_content_text.rb | 4 |
5 files changed, 12 insertions, 6 deletions
diff --git a/app/models/answer.rb b/app/models/answer.rb index 7830389..c4e8a93 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -13,6 +13,7 @@ class Answer < ActiveRecord::Base :default => '' timestamps end + attr_readonly :reference belongs_to :question has_many :comments diff --git a/app/models/question.rb b/app/models/question.rb index a6b09ed..d97c361 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -3,7 +3,7 @@ class Question < ActiveRecord::Base hobo_model # Don't put anything above this fields do - title :string + title :string, :null => false documentation :string approved :boolean, :default => false timestamps @@ -11,6 +11,7 @@ class Question < ActiveRecord::Base attr_readonly :user validates_presence_of :title + validates_length_of :title, :minimum => 2 #allow empty documentation and no category #maybe add a page for not complete questions diff --git a/app/models/question_category.rb b/app/models/question_category.rb index d6b5723..abda45a 100644 --- a/app/models/question_category.rb +++ b/app/models/question_category.rb @@ -12,6 +12,7 @@ class QuestionCategory < ActiveRecord::Base has_many :questions has_many :user_categories has_many :users, :through => :user_categories, :accessible => true + include Permissions::AnyoneCanViewAdminCanChange def self.as_select_opts diff --git a/app/models/question_content_multiple_choice.rb b/app/models/question_content_multiple_choice.rb index c3315c3..f1b3298 100644 --- a/app/models/question_content_multiple_choice.rb +++ b/app/models/question_content_multiple_choice.rb @@ -4,13 +4,14 @@ class QuestionContentMultipleChoice < ActiveRecord::Base hobo_model # Don't put anything above this fields do - content HoboFields::MarkdownString + content HoboFields::MarkdownString, :null => false timestamps end - belongs_to :question - attr_readonly :question - has_many :options, :as => :option_owner, :accessible => true, :uniq => true + belongs_to :question + attr_readonly :question + has_many :options, :as => :option_owner, :accessible => true, :uniq => true + validates_length_of :content, :minimum => 2 inherit_permissions(:question) diff --git a/app/models/question_content_text.rb b/app/models/question_content_text.rb index 78cebee..4ce78c1 100644 --- a/app/models/question_content_text.rb +++ b/app/models/question_content_text.rb @@ -4,13 +4,15 @@ class QuestionContentText < ActiveRecord::Base hobo_model # Don't put anything above this fields do - content HoboFields::MarkdownString + content HoboFields::MarkdownString, :null => false timestamps end belongs_to :question attr_readonly :question + validates_length_of :content, :minimum => 2 + inherit_permissions(:question) def new_answer_of(user) |