Here i am trying to pass one ID with the url, but that ID didn't append
with URL...

*def retrieve*
* url = "http://localhost:3000/branches/"*
* resource = RestClient::Resource.new url+$param["id"]*
* puts resource*
*end *
*
*
giving ID via commend line that is
*
*
*ruby newrest.rb id="22"
*
*
*
I have got the error like this
* `+': can't convert nil into String (TypeError)*
*
*
But all this working with mozilla rest client.............How to rectify
this problem............?PLz give me a solution



Thank you
vishnu
*
*

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/FqCyX9JEf3cJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Feb 24, 2012 at 9:18 am

    On 24 February 2012 07:53, amvis wrote:
    Here i am trying to pass one ID with the url, but that ID didn't append with
    URL...

    def retrieve
    url =  "http://localhost:3000/branches/"
    resource = RestClient::Resource.new url+$param["id"]
    puts resource
    end

    giving ID via commend line that is

    ruby newrest.rb  id="22"
    What is in newrest.rb?

    Colin
    I have got the error like this
    `+': can't convert nil into String (TypeError)

    But  all this working with mozilla rest client.............How to rectify
    this problem............?PLz give me a solution
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Amvis at Feb 24, 2012 at 9:48 am

    def retrieve
    url = "http://localhost:3000/branches/"
    resource = RestClient::Resource.new url+$param["id"]
    puts resource
    end

    giving ID via commend line that is

    ruby newrest.rb id="22"
    What is in newrest.rb?
    Colin

    newrest.rb

    *require 'rubygems'*

    *require 'rest_client'*

    *require 'json'*

    *$param = Hash.new*

    *def retrieve*

    * url = "http://localhost:3000/branches"*

    * resource = RestClient::Resource.new url +"/"+$param["id"]*

    * puts resource*

    * begin*

    * response = resource.get :content_type => :json, :accept => :json*

    * case response.code*

    * when 200*

    * puts response.to_s*

    * end*

    * rescue => e*

    * puts e*

    * end*

    *end *

    Here just i pass the ID through command line ie ruby newrest.rb id="22".
    so what i need is , the above code have this

    *url = "http://localhost:3000/branches"*

    * resource = RestClient::Resource.new url +"/"+$param["id"]*

    i have to read that id value, which coming via the command line, and
    append that value with this URL *"http://localhost:3000/branches/22"*

    So* ** resource = RestClient::Resource.new url +"/"+$param["id"] *this is
    the correct to get that value? or any way to get the value and append?
    I have got the error like this
    `+': can't convert nil into String (TypeError)

    But all this working with mozilla rest client.............How to rectify
    this problem............?PLz give me a solution
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/dvRodaDmgpMJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Feb 24, 2012 at 11:46 am

    On 24 February 2012 09:47, amvis wrote:

    newrest.rb

    require 'rubygems'

    require 'rest_client'

    require 'json'

    $param = Hash.new

    def retrieve

    url =  "http://localhost:3000/branches"

    resource = RestClient::Resource.new url +"/"+$param["id"]

    puts resource

    begin

    response = resource.get :content_type => :json, :accept => :json

    case response.code

    when 200

    puts response.to_s

    end

    rescue => e

    puts e

    end

    end

    Here just i pass the ID  through command line  ie  ruby newrest.rb id="22".
    I don't see in the code where the method retrieve is called, so I
    would not expect ruby newrest.rb to do anything.
    Also I don't see how the command line value id is being loaded into
    $param. Normally for ruby command line args I use ARGV or
    OptionParser. Google for ruby command line parameters and you will
    find how to do it.

    Colin
    so what i need is , the above code have this

    url =  "http://localhost:3000/branches"

    resource = RestClient::Resource.new url +"/"+$param["id"]

    i  have to read that id value, which coming via the command line, and append
    that value with this URL "http://localhost:3000/branches/22"

    So   resource = RestClient::Resource.new url +"/"+$param["id"]  this is the
    correct to get that value? or any way to get the value and append?
    I have got the error like this
    `+': can't convert nil into String (TypeError)

    But  all this working with mozilla rest client.............How to rectify
    this problem............?PLz give me a solution
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/rubyonrails-talk/-/dvRodaDmgpMJ.

    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/rubyonrails-talk?hl=en.


    --
    gplus.to/clanlaw

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Amvis at Feb 24, 2012 at 4:16 pm

    On 24 February 2012 09:47, amvis wrote:

    newrest.rb

    require 'rubygems'

    require 'rest_client'

    require 'json'

    $param = Hash.new

    def retrieve

    url = "http://localhost:3000/branches"

    resource = RestClient::Resource.new url +"/"+$param["id"]

    puts resource

    begin

    response = resource.get :content_type => :json, :accept => :json

    case response.code

    when 200

    puts response.to_s

    end

    rescue => e

    puts e

    end

    end

    Here just i pass the ID through command line ie ruby newrest.rb id="22".
    I don't see in the code where the method retrieve is called, so I would
    not expect ruby newrest.rb to do anything.Also I don't see how the command
    line value id is being loaded into$param. Normally for ruby command line
    args I use ARGV orOptionParser. Google for ruby command line parameters
    and you will find how to do it.

    Colin
    >
    I got it through the ARGV..

    Thankyou
    vishnu



    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/vAi7_q8EMHMJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 24, '12 at 7:54a
activeFeb 24, '12 at 4:16p
posts5
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Amvis: 3 posts Colin Law: 2 posts

People

Translate

site design / logo © 2021 Grokbase