From 716a7f64b8af28c2cab5c05af12898e9830d9b10 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer <raphael@joindiaspora.com> Date: Wed, 30 Mar 2011 15:43:32 -0700 Subject: [PATCH] Make contacts_visible accessible --- app/controllers/aspects_controller.rb | 8 +------- app/models/aspect.rb | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 947762b205..631eb653b8 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -38,9 +38,6 @@ class AspectsController < ApplicationController def create @aspect = current_user.aspects.create(params[:aspect]) - # hack, we don't know why mass assignment is not working - @aspect.contacts_visible = params[:aspect][:contacts_visible] - @aspect.save if @aspect.valid? flash[:notice] = I18n.t('aspects.create.success', :name => @aspect.name) @@ -98,7 +95,7 @@ class AspectsController < ApplicationController def edit @aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => {:person => :profile}).first - + @contacts_in_aspect = @aspect.contacts.includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } c = Contact.arel_table if @contacts_in_aspect.empty? @@ -129,9 +126,6 @@ class AspectsController < ApplicationController @aspect = current_user.aspects.where(:id => params[:id]).first if @aspect.update_attributes!(params[:aspect]) - #hack, we don't know why mass assignment is not working - @aspect.contacts_visible = params[:aspect][:contacts_visible] - @aspect.save flash[:notice] = I18n.t 'aspects.update.success', :name => @aspect.name else flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name diff --git a/app/models/aspect.rb b/app/models/aspect.rb index be6da529f5..0fd4a82534 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -15,7 +15,7 @@ class Aspect < ActiveRecord::Base validates_length_of :name, :maximum => 20 validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false - attr_accessible :name + attr_accessible :name, :contacts_visible before_validation do name.strip! -- GitLab