Allow me to second the recommendation to read up on ActiveResource - this is
exactly what it's designed for, and in fact if you're also developing the
ReST API, you can use ActiveResource to impose convention (over
configuration) in your API - plus you'll have a nice test rig when you're
done.

Only issue is whether enough people in the Ruby community see AR this way
and whether it will continue to be maintained.

m


On Fri, Mar 4, 2011 at 10:42 AM, exequiel <efu...@gmail.com> wrote:

> Hi,
>
> I never tried this, but it should be something like this:
>
>  required_parameters = ["param1=value1", "param2=value2"]
>  ...
>   self.response_body = proc do |response, output|
>    net_http.start do |http|
>       http.get(uri.path + '?' + required_parameters.join('&'))
>        case res
> ...
>
> Maybe, you need to "escape" the required parameters.
>
> Cheers.
>
> On Mar 2, 11:57 am, gs84 <salimat...@gmail.com> wrote:
> > On 1 mar, 19:32, exequiel <efu...@gmail.com> wrote:
> >
> > > Hi,
> >
> > > To send data from an action I do this:
> >
> > > def send_mydata
> > >   ...
> > >   uri = URI.parse(link)
> > >   net_http = Net::HTTP.new(uri.host, uri.port)
> > >   net_http.open_timeout = timeout
> > >   net_http.read_timeout = timeout
> > >   net_http.use_ssl = (uri.scheme == 'https')# enable SSL/TLS
> > >   if net_http.use_ssl?
> > >     net_http.cert =
> > > OpenSSL::X509::Certificate.new(File.read(cert_path))
> > >     net_http.key = OpenSSL::PKey::RSA.new(File.read(key_path))
> > >     net_http.verify_mode = OpenSSL::SSL::VERIFY_NONE
> > >   end
> >
> > >   self.response_body = proc do |response, output|
> > >     net_http.start do |http|
> > >       http.request_get(uri.request_uri()) do |res|
> > >         case res
> > >           when Net::HTTPSuccess then
> > >             res.read_body do |segment|
> > >               response.write(segment)
> > >             end
> > >           when Net::HTTPRedirection then
> > >             response.close() unless response.closed?
> > >             return
> > >           else
> > >             raise "Net::HTTPResponse error: #{res.message.to_s()}"
> > >          end
> > >       end
> > >     end
> > >   end
> > > end
> >
> > Hi,
> > How can i set parameters in this case?
> >
> > Thanks
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to