Class: HouseholdsController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- HouseholdsController
- Defined in:
- app/controllers/households_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #ignore_suggested ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #suggested ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/households_controller.rb', line 34 def create @household = current_organization.households.create(params[:household]) # NOTE: No mind is paid to any household these people might already be in params[:individuals].reject(&:empty?).each do |i| @household.individuals << current_organization.individuals.find(i) end if @household.save redirect_to @household else render :new end end |
#ignore_suggested ⇒ Object
65 66 67 68 69 |
# File 'app/controllers/households_controller.rb', line 65 def ignore_suggested suggested = SuggestedHousehold.find(params[:suggested_id]) suggested.update_attributes(:ignored => true) redirect_to suggested_households_path end |
#index ⇒ Object
54 55 56 57 |
# File 'app/controllers/households_controller.rb', line 54 def index @households = current_organization.households.order(:created_at) @households = @households.paginate(:page => params[:page], :per_page => 20) end |
#new ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/controllers/households_controller.rb', line 5 def new @household = Household.new if params[:individuals] params[:individuals].each do |i| @household.individuals << current_organization.individuals.find(i) end end end |
#show ⇒ Object
49 50 51 52 |
# File 'app/controllers/households_controller.rb', line 49 def show @household = current_organization.households.find(params[:id]) @actions = @household.actions.includes(:person, :organization).paginate(:page => params[:page], :per_page => 20) end |
#suggested ⇒ Object
59 60 61 62 63 |
# File 'app/controllers/households_controller.rb', line 59 def suggested hs = HouseholdSuggester.new(current_organization) @by_address = hs.by_address @by_spouse = hs.by_spouse end |
#update ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/households_controller.rb', line 14 def update @household = current_organization.households.find(params[:id]) flash[:notice] = [] unless params[:individual_ids].nil? @household.individuals << current_organization.individuals.find(params[:individual_ids]) end @household.update_attributes(params[:household]) @household.update_member_addresses if @household.overwrite_member_addresses if @household.save flash[:notice] = "Your changes have been saved" else flash[:alert] = @household.errors..to_sentence end redirect_to(@household) end |