【问题标题】:After posting some data using httparty, how can I access the posted values in controller?使用 httparty 发布一些数据后,如何访问控制器中发布的值?
【发布时间】:2012-05-06 03:55:32
【问题描述】:

我已经使用 httparty 发布过。

例如

options={ 
  :foo => '123'
  :bar => 'second',
  :baz => 'last thing'
}

HTTParty.post("localhost/tests" , options)

如何在远程应用控制器中检索选项参数: 例如

#post /tests
def create
@k=options[:name]  -------> Here is my question, How can I access options[:name]?

我的意思是我应该将选项作为 create 方法的参数传递吗?比如:

def create(options)
@k=options[:name]

【问题讨论】:

    标签: ruby-on-rails post httparty


    【解决方案1】:

    好吧,它终于对我有用了。我应该分别检索每个字段而不是整体检索。很高兴!所以现在我有 2 个 rails 应用程序。只需分别包装字段并分别获取它们,我就可以发布和检索。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-18
      • 1970-01-01
      • 2021-01-15
      • 1970-01-01
      • 2018-01-20
      • 1970-01-01
      相关资源
      最近更新 更多