Class: Census::DataGroupsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Census::DataGroupsController
- Defined in:
- app/controllers/census/data_groups_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/census/data_groups_controller.rb', line 13 def create @data_group = DataGroup.new(params[:data_group]) if @data_group.save flash[:notice] = "Created #{@data_group.name}" redirect_to census_admin_path else render :action => 'new', :status => :unprocessable_entity end end |
#destroy ⇒ Object
39 40 41 42 43 44 |
# File 'app/controllers/census/data_groups_controller.rb', line 39 def destroy @data_group = DataGroup.find(params[:id]) @data_group.destroy flash[:notice] = "Deleted #{@data_group.name}" redirect_to census_admin_path end |
#edit ⇒ Object
24 25 26 |
# File 'app/controllers/census/data_groups_controller.rb', line 24 def edit @data_group = DataGroup.find(params[:id]) end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/census/data_groups_controller.rb', line 5 def index @data_groups = DataGroup.all end |
#new ⇒ Object
9 10 11 |
# File 'app/controllers/census/data_groups_controller.rb', line 9 def new @data_group = DataGroup.new(params[:data_group]) end |
#sort ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/controllers/census/data_groups_controller.rb', line 46 def sort group_positions = params[:data_group].to_a DataGroup.all.each_with_index do |group, i| group.position = group_positions.index(group.id.to_s) + 1 group.save end render :text => 'ok' end |
#update ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/census/data_groups_controller.rb', line 28 def update @data_group = DataGroup.find(params[:id]) if @data_group.update_attributes(params[:data_group]) flash[:notice] = "Saved #{@data_group.name}" redirect_to census_admin_path else render :action => 'edit', :status => :unprocessable_entity end end |