Class: AlchemyDomains::Admin::DomainsController
- Inherits:
-
Alchemy::Admin::ResourcesController
- Object
- Alchemy::Admin::ResourcesController
- AlchemyDomains::Admin::DomainsController
- Defined in:
- app/controllers/alchemy_domains/admin/domains_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/alchemy_domains/admin/domains_controller.rb', line 35 def create params[:domain][:localizations_attributes].delete_if { |k, v| v[:language_id] == "0" } @domain = Domain.new(params[:domain]) @domain.save render_errors_or_redirect( @domain, admin_domains_path, flash_notice_for_resource_action ) end |
#edit ⇒ Object
12 13 14 15 16 17 |
# File 'app/controllers/alchemy_domains/admin/domains_controller.rb', line 12 def edit @domain = Domain.find(params[:id]) @languages = Alchemy::Language.published.all (@languages - @domain.languages).map { |l| @domain.localizations.build(:language => l) } render :layout => !request.xhr? end |
#new ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/alchemy_domains/admin/domains_controller.rb', line 5 def new @domain = Domain.new @languages = Alchemy::Language.published.all @languages.map { |l| @domain.localizations.build(:language => l) } render :layout => !request.xhr? end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/alchemy_domains/admin/domains_controller.rb', line 19 def update params[:domain][:localizations_attributes].map do |k, v| if v[:language_id] == "0" v[:_destroy] = '1' v.delete(:language_id) end end @domain = Domain.find(params[:id]) @domain.update_attributes(params[:domain]) render_errors_or_redirect( @domain, url_for({:action => :index}), flash_notice_for_resource_action ) end |