devise - i am having problems redirecting after a method call in Rails -


i have got custom def methods working , updating table in database know having issues redirecting accounts index page. go update.html.erb page. source of issue mayb in routes and/or authenication issue cancancan/devise ? maybe before_filter :authenticate_user! when change redirect_to accounts_url, this, render and/or redirect called multiple times in action. please note may call render or redirect, , @ once per action. note neither redirect nor render terminate execution of action, if want exit action after redirecting, need "redirect_to(...) , return".

my controller , declarations @ top , update method

 class accountscontroller < applicationcontroller  before_action :set_account, only: [:show, :edit, :deposit,   :withdrawl,:update, :destroy]   # before_filter :set_account, only: [:show, :edit, :deposit, :withdrawl,   :update, :destroy]   before_filter :authenticate_user!   respond_to :js, :html   #respond_to :html    def update     @account = account.find(params[:id])      @account.update(account_params)     respond_with(@account)     return accounts_url  end 

my routes

   rails.application.routes.draw     # 'accounts/update'    #get 'accounts/new'    # 'accounts/create'    # 'accounts/edit'    # 'accounts/destroy'    # 'accounts/index'    # 'accounts/show'    # 'accounts/deposit'    # 'accounts/withdrawl'    #get 'account/new'    # 'account/create'    # 'account/edit'    # 'account/destroy'    # 'account/index'    #  'account/show'    #  'account/deposit'    # 'account/withdrawl'    devise_for :users   'admin' => 'admin#index'   'users/index'   'accounts/index'   'accounts/show'    #get 'accounts/show'     # resources :accounts   resources :students   #controller :sessions  #  'login' => :new  #  post 'login' => :create  #  delete 'logout' => :destroy   #end   root 'store#index', as: 'store'     #get 'sessions/create'     #get 'sessions/destroy'     #resources :users     resources :orders     resources :line_items     resources :carts     'store/index'     resources :menus    resources :users     resources :accounts      collection       post 'deposit', :action => :deposit       post 'withdrawl', :action => :withdrawl     end    end    # priority based upon order of creation: first created -> highest     priority.    end 

you should change return accounts_url redirect_to accounts_url.

this way set response. return of action not matter.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -