English 中文(简体)
向铁路公司发送客户-Rub路边信息的最佳方式?
原标题:Best way to send information from a client-side Ruby script to a Rails app?

www.un.org/Depts/DGACM/index_spanish.htm 我愿通过从客户-B.R.T.B.书上发送跟踪数据信息,在铁路应用的轨迹(如音乐)数据库中设定条目。 我只需要制造和摧毁文字上的轨道,我不需要有任何网络接口,我不担心目前的真实性/授权性。 是否有人请通过(a) 如何妥善建立铁路(使用铁路2.3.8)和(b) 如何从Ruby路口发送数据?

在此,我迄今为止采取的办法:

我建立了跟踪模型和跟踪控制器。 这里是《跟踪控制器法》:

class TracksController < ApplicationController

  def create
    @track = Track.new(params[:track])
    respond_to do |format|  
      if track.save
        format.any(:xml, :json) { head :ok }
      else
        format.xml { render :xml => @track.errors, :status => :unprocessable_entity}
        format.json { render :json => @track.errors, :status => :unprocessable_entity}
      end
    end
  end

  def destroy
    @track = Track.find(params[:id])  
    @track.destroy
    respond_to do |format|
      format.any(:xml, :json) { head :ok }
    end
  end    

end

我确定了以下路线:

  map.resources :tracks, :only => [:create, :destroy]

为了从鲁比书上发送信息,我尝试(1)使用主动资源,(2)使用网/http://www.ml格式的跟踪信息。 对于后者,我不肯定如何用净额/http://www.ml提出员额要求,我也不清楚如何妥善安排Xml。 例如,我能否在轨物体上使用xml?

事先感谢你的帮助。

最佳回答

我看不出与您的Alfonso先生有任何特殊问题,或看你如何与吉卜赛人协会客户联系。 但是,为了使其符合《教育标准》,请将标语作为XML或JSON。 确实,你可以简单地叫to_xmlto_json 上< 编码><@ Line/code>。 这些职能接受进一步控制产出的备选办法。 例如,如果您希望将部分数据排除在其APICA中,你可以通过<代码>:选择。 See the docs associated for more info.

至于你的文字,我个人喜欢HTTParty 转而主动Resource - 非常简单、容易理解,并且不要求您将本份内容与主动的Resource way相吻合。 实例是一个良好的开端,或对Chargies gem有了一个更长的例子。 HTT: 所涉缔约方仅接收哈希,将其兑换成XML或JSON。 你们不需要在你的印章中找到一个轨迹(除非你真的想要)。 你的文字就是这样:

require  httparty 

class TrackPoster
  include HTTParty
  base_uri  http://hostname.com 

  def self.create_track(artist, song)
    post( /tracks , :body => { 
      :track => { :artist => artist, :song => song }})
  end
end

TrackPoster.create_track( The Beatles ,  Let It Be )

这项呼吁将使教区XML/JSON成为教区。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签