Class: Iugu::AccountDomainsController
- Inherits:
-
AccountSettingsController
- Object
- AccountSettingsController
- Iugu::AccountDomainsController
- Defined in:
- app/controllers/iugu/account_domains_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #instructions ⇒ Object
- #primary ⇒ Object
- #update_subdomain ⇒ Object
- #verify ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/iugu/account_domains_controller.rb', line 17 def create @account = current_user.accounts.find(params[:account_id]) if @account.account_domains << @account_domain = AccountDomain.create(params[:account_domain]) redirect_to account_domains_instructions_path(:account_id => params[:account_id], :domain_id => @account_domain.id)#, :notice => notice = I18n.t("iugu.notices.domain_created") else @account_domains = @account.account_domains.where(:account_id => params[:account_id]) render :index end end |
#destroy ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/iugu/account_domains_controller.rb', line 27 def destroy flash[:group] = :account_domain begin @account = current_user.accounts.find(params[:account_id]) @domain = @account.account_domains.find(params[:domain_id]) @domain.destroy notice = I18n.t("iugu.notices.domain_destroyed") rescue notice = I18n.t("iugu.notices.domain_not_found") end redirect_to account_domains_index_path(params[:account_id]), :notice => notice end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/iugu/account_domains_controller.rb', line 7 def index unless IuguSDK::enable_custom_domain == false && IuguSDK::enable_account_alias == false @account = current_user.accounts.find(params[:account_id]) @account_domains = @account.account_domains.where(:account_id => params[:account_id]) @account_domain = AccountDomain.new else raise ActionController::RoutingError.new("Not found") end end |
#instructions ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'app/controllers/iugu/account_domains_controller.rb', line 40 def instructions begin @account = current_user.accounts.find(params[:account_id]) @domain = @account.account_domains.find(params[:domain_id]) rescue redirect_to account_domains_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.domain_not_found") end end |
#primary ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/iugu/account_domains_controller.rb', line 63 def primary begin @account = current_user.accounts.find(params[:account_id]) @domain = @account.account_domains.find(params[:domain_id]) @domain.set_primary redirect_to account_domains_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.domain_set_primary") rescue redirect_to account_domains_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.domain_not_found") end end |
#update_subdomain ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/iugu/account_domains_controller.rb', line 74 def update_subdomain if IuguSDK::enable_account_alias == true @account = current_user.accounts.find(params[:account_id]) if @account.update_attributes(params[:account]) redirect_to account_domains_index_path(@account.id), :notice => I18n.t("iugu.notices.subdomain_updated") else @account_domains = @account.account_domains.where(:account_id => params[:account_id]) @account_domain = AccountDomain.new render :index end else raise ActionController::RoutingError.new('Not found') end end |
#verify ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/iugu/account_domains_controller.rb', line 49 def verify begin @account = current_user.accounts.find(params[:account_id]) @domain = @account.account_domains.find(params[:domain_id]) if @domain.verify redirect_to account_domains_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.domain_verified") else redirect_to account_domains_instructions_path(:account_id => params[:account_id], :domain_id => params[:domain_id]), flash: { :error => I18n.t("iugu.notices.domain_not_verified") } end rescue redirect_to account_domains_index_path(params[:account_id]), flash: { :error => I18n.t("iugu.notices.domain_not_found") } end end |