Hello,
I’m playing around with net/http and open-uri Ruby Libraries… I’m
trying to post to my own rails simple new action method.
Here’s my irb :
irb(main):013:0> res =
Net::HTTP.post_form(URI.parse(“http://localhost:3002/blog2/new”),
{“commit” => “Save”,
“signature_id” => “”, “signature_content” => “hey rails, it’s me ruby,
your lover, why can you not insert me”})
=> #<Net::HTTPOK 200 OK readbody=true>
irb(main):014:0>
Here’s the log (from rails)
Processing Blog2Controller#new (for 127.0.0.1 at 2006-09-03 09:13:55)
[POST]
Session ID: 1629fe20fc50bebad043d8f6cb6a7a83
Parameters: {“commit”=>“Save”, “action”=>“new”, “signature_id”=>“”,
“controller”=>“blog2”, “signature_content”=>“hey rails, it’s me ruby,
your lover, why can you not insert me”}
Signature Columns (0.017050) SHOW FIELDS FROM signatures
SQL (0.000317) BEGIN
SQL (0.000310) COMMIT
Rendering blog2/new
Rendered blog2/_form (0.00146)
Completed in 0.06593 (15 reqs/sec) | Rendering: 0.02027 (30%) | DB:
0.01768 (26%) | 200 OK [http://localhost/blog2/new]
How come i’ve got 200 OK , but i didn’t get my INSERT Query run ???
How can i fix it?
Oh, btw here’s my new action method from my Blog2 controller
def new
@signature = Signature.new
return unless request.post?
@signature = Signature.new(params[:signature])
if @signature.save
expire_fragment(:action => “list”, :part => “signatures”)
expire_fragment(:action => “list”, :part => “count”)
redirect_to(:action => “list”)
end
end
I would be verry grateful 4 somebody who can give me a good solution for
this.
ps.
Actually i’ve posted this to Rails maillist but nobody answered …
sigh … don’t whether my question’s too dumb or too difficult … so i
consider it would fit to go into this ruby-talk maillist. Right now
i’m playing with http-access2 library (from RAA)… but i’m still
stuck on how to post like this. I actually need to do like Perl::LWP
POST like this :
cat /home/ariekeren/tmp/test-xml/2000.xml | POST -c “text/xml”
http://203.128.65.50:14013/cgi-bin/sendmyscript
but i like to make it simpler in example above (this thread) to test
whether i’m succeeded or not to post from ruby just like LWP POST in
Perl.
–
Name : Arie Kusuma A., A.K.A Arie, A.K.A ariekeren / YM! = riyari3
http://ariekusumaatmaja.wordpress.com
Let’s build Ruby Indonesia stronger
Go go go Ruby go!
Mp3Info.open(“Linkin\ Park\ -\ Abyss.mp3”) { |f| puts f }