From 6238abea422a1be14d5f3d8cbacd78f2e72fd466 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Feb 2013 09:09:10 -0500 Subject: group defaults --- app/controllers/groups_controller.rb | 2 +- app/models/group.rb | 3 +++ app/views/groups/_form_core.html.haml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 74ad7c8..d48707c 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -11,7 +11,7 @@ class GroupsController < ApplicationController end def new - @group = Group.new + @group.active = true; end def create diff --git a/app/models/group.rb b/app/models/group.rb index e0cfaab..c459530 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -5,6 +5,9 @@ class Group < ActiveRecord::Base has_many :group_permissions, :dependent => :destroy has_many :permittances, :foreign_key => :target_group_id, :class_name => "GroupPermission", :dependent => :destroy + validates :name, + :presence => true + def to_s self.name end diff --git a/app/views/groups/_form_core.html.haml b/app/views/groups/_form_core.html.haml index 1f9a39f..02f296b 100644 --- a/app/views/groups/_form_core.html.haml +++ b/app/views/groups/_form_core.html.haml @@ -1,4 +1,4 @@ .inputs = f.input :name, :label => t('groups.form.name.label'), :hint => conditional_hint('groups.form.name.hint') - = f.input :active, :label => t('groups.form.active.label'), :hint => conditional_hint('groups.form.active.hint') = f.input :comment, :label => t('groups.form.comment.label'), :hint => conditional_hint('groups.form.comment.hint') + = f.input :active, :label => t('groups.form.active.label'), :hint => conditional_hint('groups.form.active.hint') -- cgit v1.2.3