Ruby On Rails, params lost after redirect -


i have page user pays fees, , on submit gets redirected same page showing payment done. i'm passing id on redirect, lost causing error.

here controller action:

def pay_all_fees       @target_action='pay_all_fees'     @target_controller='parent_wise_fee_payments'         if params[:id].present?       id = params[:id]       else id = 4         end        @students=student.find_all_by_sibling_id(guardian.find(id).ward_id)       @guardian = guardian.find(id)       @students.each |student|             fetch_all_fees        end        if request.post?       status=true       multifeestransaction.transaction         multi_fees_transaction= multifeestransaction.create(params[:multi_fees_transaction])         begin           finance_transactions=financetransaction.create!(params[:transactions].values)         rescue exception => e           status=false         end          if status , (multi_fees_transaction.valid? && finance_transactions.all?(&:valid?))           multi_fees_transaction.finance_transactions=finance_transactions           flash[:notice]="#{t('fees_paid')}"         else           flash[:notice]="#{t('fee_payment_failed')}"           raise activerecord::rollback         end       end       redirect_to :controller => 'parent_wise_fee_payments', :action => 'pay_all_fees', :id=>id     end       get_paid_fees    end 

and error in production log:

processing parentwisefeepaymentscontroller#pay_all_fees (for 178.135.80.106 @ 2015-08-03 13:11:29) [post]   parameters: {"multi_fees_transaction"=>{"student_id"=>"4", "payment_mode"=>"cash", "payment_note"=>"", "amount"=>"500.00", "transaction_date"=>"2015-08-03"}, "controller"=>"parent_wise_fee_payments", "transactions"=>{"4"=>{"payee_type"=>"student", "title"=>"receipt no.. (multiple fees) f3", "payment_mode"=>"cash", "finance_id"=>"3", "category_id"=>"14", "payment_note"=>"", "payee_id"=>"4", "amount"=>"", "finance_type"=>"financefee", "transaction_date"=>"2015-08-03"}, "2"=>{"payee_type"=>"student", "title"=>"receipt no.. (multiple fees) f3", "payment_mode"=>"cash", "finance_id"=>"3", "category_id"=>"14", "payment_note"=>"", "payee_id"=>"1", "amount"=>"500", "finance_type"=>"financefee", "transaction_date"=>"2015-08-03"}}, "action"=>"pay_all_fees", "authenticity_token"=>"ns37sh/td/0i5pymlgfg6bzeb2shgjwjqgmuv3i3cne=", "transaction_date"=>"2015-08-03"} username : admin role : admin rendering template within layouts/application rendering parent_wise_fee_payments/pay_all_fees  actionview::templateerror (undefined method `full_name' nil:nilclass) on line #31 of vendor/plugins/acme_parent_wise_fee_payment/app/views/parent_wise_fee_payments/pay_all_fees.html.erb: 28:       <div class="val themed_text"> 29:         <span>:</span> 30:           <div class="val-align"> 31:             <%= @guardian.full_name %> 32:           </div> 33:       </div> 34:  

so id null after redirect. can notice production log id missing after action "pay_all_fees". please me fix this? there way force passing id authenticity token example?

update:

before getting page, user searches guardian, i'm passing id search page current page. need same id after redirect, don't know how.

try this:

 if request.post?         student_id=params[:multi_fees_transaction]["student_id"] ..........       redirect_to :controller => 'parent_wise_fee_payments', :action => 'pay_all_fees', :student_id=>student_id 

this way can use student_id id or something.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -