ruby on rails - Retrieve Incoming Parameters in Rails4 -


i'm posting parameters remote url in rails4 application, /orders/:id route show controller method.

the parameters sent service application , service returning bunch of parameters applications' /fail or /success pages depending on if response successful or not. can see incoming params logs.

i create ordertransaction parameters in order controller, how can this?

orders_controller.rb    def success     ### create ordertransaction here incoming parameters!     @transaction = ordertransaction.new(????????)   end    def fail     ### create ordertransaction here incoming parameters!     @transaction = ordertransaction.new(????????)   end 

incoming parameters in logs =>

started post "/orders/fail" 127.0.0.1 @ 2014-06-01 13:40:28 +0300 processing orderscontroller#fail html parameters:    {     "tranid"=>"",      "type"=>"auth",      "refreshtime"=>"5",      "lang"=>"tr",      "amount"=>"30",      "acqbin"=>"490740",      "clientip"=>"193.140.28.145",      "name"=>"akbank",      "cardholdername"=>"dsadas dasdsa",      "okurl"=>"http://localhost:3000/orders/success",     "failurl"=>"http://localhost:3000/orders/fail",     "storetype"=>"3d_pay_hosting",     "response"=>"declined"     ....   } 

order.rb =>

class order < activerecord::base   belongs_to :user   belongs_to :participation   has_one :transaction, :class_name => "ordertransaction" end 

order_transaction.rb =>

class ordertransaction < activerecord::base   belongs_to :order end 

routes.rb =>

post 'orders/success' => 'orders#success' post 'orders/fail' => 'orders#fail' resources :orders, only: [:index, :new, :create, :show] 

orders_controller.rb =>

require 'digest/sha1'  class orderscontroller < applicationcontroller   before_filter :authenticate_user!   before_action :set_order, only: [:show, :edit, :update, :destroy]   skip_before_action :verify_authenticity_token    def index     @orders = order.all   end    def show     @hashing = {       clientid: pos['clientid'],       oid: time.now.to_i.to_s,       amount: @order.participation.examination.exam_fees.first.fee.to_s,       okurl: pos['okurl'],       failurl: pos['failurl'],       islemtipi:pos['islemtipi'],       taksit: '',       rnd: time.now.to_i.to_s,     }   end    # /orders/new   def new     @order = order.new   end    def create     @order = order.new(order_params)     @order.user_id = current_user.id     respond_to |format|       if @order.save         ...       else         ...       end     end   end    def success     ### create ordertransaction here incoming parameters!     @transaction = ordertransaction.new(????????)   end    def fail     ### create ordertransaction here incoming parameters!     @transaction = ordertransaction.new(????????)   end    private    def set_order     @order = order.find(params[:id])   end    def order_params     params.require(:order).permit(:id, :user_id, :participation_id, :amount, :cardholdername)   end end 

orders/show.html.erb=>

<%= simple_form_for(@order, html:{class: "well"}, :url => "https://testsanalpos.est.com.tr/servlet/est3dgate", :method => :post) |f| %>   <% @hashing.each |k, v| %>     <%= f.input k, input_html: {name: k, value: v}, as: :hidden %>   <% end %>   <%= f.button :submit, "approve" %> <% end %> 

you this:

#app/controllers/orders_controller.rb def success    orders.new(order_params) end  private  def order_params     params.permit(:client_ip, :etc, :etc) end 

--

this use conventional strong_params pattern in rails, whitelist params require. should work okay considering params hash populated data remote service


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -