在Ruby中的方法之间传递符号

时间:2016-12-20 23:59:19

标签: ruby-on-rails ruby

我试图在我重定向到的另一种方法中使用符号的值。好像我无法从method_2访问:customer_id。我希望能够从method_2访问method_1中设置的:customer_id的值。

def method_1
  user = User.find_by(:uid => params[:userid]) # this works
  redirect_to :m2, :customer_id => user.cust_id
end

def method_2
  @cid = params[:customer_id]

  # these don't print the value of customer_id
  Rails.logger.info("Customer ID: #{@cid}")
  Rails.logger.info("Customer ID: #{params[:customer_id]}")
end

# this is the line I have in routes.rb
get 'demo/method_2' => 'demo#method_2', :as => :m2

0 个答案:

没有答案