Hi, I'm using the following code to download a page through a POST request:
require 'net/http'
require 'uri'
res = Net::HTTP.post_form(URI.parse('http://example.com'),{'post'=>'1'})
puts res.split("Date")
The URL I originally used has been replaced with example.com
It works great, but when I try to call split (last line) it return...
Hello,
I have a collection of Blog items.
@blogs = Blog.find(:all)
Each blog has a description textfield with some text. What I would like to do is splitting the @blogs objects into 3 divs, but with roughly the same characters in each column.
<div id="left">
#blog1 (653 characters)
</div>
<div id="center">
#blog2 (200 characte...
I had previously a mailer set up to send me emails to all user accounts. But now I'm trying to debug it. So I gutted it out completely and it still sends emails to me.
I have absolutely no reasoning or understanding as to why. Insanity! :D
controller
def org_blast_send
Delayed::Job.enqueue OrgBlast.new(params[:subject], params[:edi...
I've got a Rails app with blog entries that I want to update from a separate Blog.git repo.
I envision my workflow as something like:
Write new blog entry
Push to remote Git repo
Call cap deploy:update, which will invoke a Rake task to update the database with any changed or new entries
The hitch here is finding which files have cha...
I was wondering if there is a shorter, better or cleaner way to assign and use class variables in PHP, then through $this->instance_variable ?
class Bar {
# internal variables
var $foo = "Hello World";
public function foo() {
return $this->foo;
}
}
I am not very familiar with all PHP's variable scoping, but from what I u...
What is the difference between
case item.class
when MyClass
# do something here
when Array
# do something different here
when String
# do a third thing
end
and
case item.class
when MyClass.class
# do something here
when Array.class
# do something different here
when String.class
# do a third thing
end
For some reason, ...
Hey Guys,
Hope someone can help me out. Currently working on a RoR project that needs a strange kind of functionality.
Basically, I have two types of users named User and Researcher. Users can create forms and these forms are stored in the db and filled in by researchers.
I have this basic schema
create_table "form_fields", :force =...
Hi,
The site is a simple community where each user creates posts and users may "like" them or "unlike" them.
I have a Post and a Like model. Currently, I'm listing all posts and also the likes size for each post through post.likes.size . The button to like a post is also working.
What i don't know how to do is how to depending on the...
I'm working on a Rails site that uses the Radiant CMS and am building stateful navigation as per the first method in this link.
I'm matching the URL on regular expressions to determine whether or not to show the active state of each navigation link. As an example, here are two sample navigation elements, one for the Radiant URL /commu...
I'm renovating an application to work through AJAX. Unfortuantely, the action url in my form is getting messed up somehow. Do you know why this is?
Currently my swfupload param of :
upload_url: $('#new_video').attr("action"),
is returning a
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 302.
SwfU...
I'm running Rspec 2.0.0rc on Windows 7. I am also running the win32console gem (1.3.0 x86-mingw32).
The colours aren't being displayed - everything is showing up in boring old white/grey.
What am I doing wrong?
Edit: I also tried Rspec 2.0.0. and had the same problem
...
1) I've got x-code 3.2.1
2) I've installed GIT and RVM
3) I've installed Ruby 1.9.2, it's installed 100%
4) I run 'ruby -v' but instead of seeing
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
I see
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
I don't see what I could be going wrong
...
I have an array of structs. Each struct has the following two attributes:
win %
# of wins
I want to sort the array of structs by win %; however, for only those structs with at least 3 wins.
Any suggestions?
...
I've been playing around with jqTouch to create a mobile version of my Rails app.
I use Devise for authentication, but it won't work with jqtouch.
It has something to do with jqtouch's "auto-ajax" functionality. I used a "rel=external" attribute on my sign in form to get it to do something at all (before it simply wouldn't do anythin...
Hi. I've got class A
class A
attr_reader :b
def b=param
@b = param
print "success"
end
end
>> a = A.new
>> a.b = "hello world!"
#> "success"
#> "hello world!"
>> a.b << " and goodbye!"
#> "helo world! and goodbye!"
Where is my "success" ? :)
I want to print 'success' EVERY TIME my variable changed.
I can't just write...
I'm trying to seed a database in Rails 3 with images using CarrierWave, however nothing I try seems to work short of having to upload them all by hand.
pi = ProductImage.new(:product => product)
pi.image = File.open(File.join(Rails.root, 'test.jpg'))
pi.store_image! # tried with and without this
product.product_images << pi
product.save...
I have an idea for a simple web application and I've heard a lot about Ruby, Ruby on Rails, Python, PHP, etc.
But what language do you think is better to have working prototypes and get the application running online really quick?
NOTE: This is not a question about the language's performance, I am just trying to find the best language...
I have my site running fine with a simple 'merb' command. I'd like to spawn multiple processes, or threads or whatever, so that a long DB request (or more often, a long PDF building request) doesn't hang everyone else on the server.
I've tried to use "merb -c3", but receive an error saying Daemonized mode is not available.
Any other ...
Given a ruby script with a bunch of functions, how can you unit test the functions in the script without running the script itself? Here is an example script, and here is its unit test.
For example, using require or load in my unit test causes the script to execute before the tests execute. I have many of these scripts and I really pref...
I'm trying to read an RSS field and add some metadata to each item in Ruby, outputting another valid RSS feed.
I'd like to do this in one pass without reading the entire RSS feed into memory for performance reasons, but I've been playing with libxml-ruby and the Reader object doesn't seem to be able to print out the current element it h...