I am having this problem which I can't seem to get my head around. I would like some help on this.
@user.update_languages(params[:language][:language1], params[:language][:language2], params[:language][:language3])
lang_errors = @user.errors
logger.debug "--------------------LANG_ERRORS----------101-------------" + lang_erro...
I'm using Mechanize to extract the links from the page.
To ease with development, I'm using fakeweb to do superfast response to get less waiting and annoying with every code run.
tags_url = "http://website.com/tags/"
FakeWeb.register_uri(:get, tags_url, :body => "tags.txt")
agent = WWW::Mechanize.new
page = agent.get(tags_url)
page.lin...
At a glance they seem to be pretty much the same solution to the same problem, but Jammit must have some key difference or improvement that I haven't picked up on, or its author would have just used asset_packager. :-)
Can anyone enlighten me?
...
I don't know whether it's really easy and I'm out of my mind....
In Ruby's regular expressions, how to match strings which do not contain two consecutive underscores, i.e., "__".
Ex:
Matches: "abcd", "ab_cd", "a_b_cd", "%*##_@+"
Does not match: "ab__cd", "a_b__cd"
-thanks
EDIT: I can't use reverse logic, i.e., checking for "__" str...
I am parsing a text file and want to be able to extend the sets of tokens that can be recognized easily. Currently I have the following:
if line =~ /!DOCTYPE/
puts "token doctype " + line[0,20]
@ast[:doctype] << line
elsif line =~ /<html/
puts "token main HTML start " + line[0,20]
html_scanner_off = false
...
I am creating a web application which requires threading and I am trying to figure out which langauge between PHP and Ruby has better threading functionality and better performance.
Even if not in built, some easy work arounds or add-ons.
...
I'm looking to define a method that lets me pass options; something like:
@user.tasks(:completed => true)
I thought something like this would work in my user model (but it's not):
User.rb model
def tasks(options)
tasks.find(:all, options)
end
How would I define the method correctly to let me use @user.tasks(:completed => t...
I have two models: CreditCard and BlacklistItem::CreditCard. If I search for a BlacklistItem::CreditCard first, I get the expected behaviour:
>> BlacklistItem::CreditCard.find(:all).first
=> #<BlacklistItem::CreditCard id: 5, *snip* >
>>
If I search for a CreditCard first, when I go to look for BlacklistItem::CreditCard items later ...
Hi:) I have manually set Ruby 1.9.1. I have installed it via
./configure --prefix=/opt
make
make install
The target 'uninstall' does not exist in generated Makefile ...
How to do uninstallation correctly?
PS: I also believe that it is necessary to remove all the gems.
For this I use
#!/bin/sh
gem list --local | grep [^\*] | cut -d '...
I have an app with an Account model. Each Account belongs_to a sport, which I would usually have as a Sport model and in the DB. But as this isn't really something that will change and is not administered by the end users I thought that it might be better to put it as an integer column in the Account model and map to a hash using a clas...
Does anyone know how to use Win32's BitBlt() using Ruby? It seems like you need to use a destination DC (device context) and how can Ruby handle that? I use GetPixel() and it is really slow even to get 100 pixels (takes about 10 seconds). thanks.
...
Getting to the Ruby One-click installer for Windows, we may go to
http://www.ruby-lang.org/en/downloads/
and then
http://rubyinstaller.org/download.html
however over there, it seems that
Ruby 1.8.6 RC1 (patchlevel 383)
is actually more recent than
Ruby 1.8.6 RC2 (patchlevel 27)
or
Ruby 1.8.6 Final (patchleve...
I'm aggregating RSS feeds using FeedTools.
I followed this tutorial: http://simonwoodside.com/weblog/2008/12/7/ruby%5Fon%5Frails%5Ffeedrss%5Faggregator/ and everything functioned fine.
The problem is I want to filter some of the hashes that exist within the array [:items] from inside the parsed feed hash.
Here's the RSS cached feed obj...
Hi,
I'm currently learning Ruby, and am enjoying most everything except a small string comparason issue.
answer = gets()
if (answer == "M")
print("Please enter how many numbers you'd like to multiply: ")
elsif (answer. == "A")
print("Please enter how many numbers you'd like to sum: ")
else
print("Invalid answer....
How do I download a file over HTTP using Ruby?
...
I am a university student and it's time to buy textbooks again. This quarter there are over 20 books I need for classes. Normally this wouldn't be such a big deal, as I would just copy and paste the ISBNs into Amazon. The ISBNs, however, are converted into an image on my school's book site. All I want to do is get the ISBNs into a string...
Okay, so I've been doing web design for about a year or two, and I've decided that I want to learn a Programming Language, because I've figured out that's what interest me more.
I start out learning Python, got about about 1/4 of the way through Dive into Python, but then decided to go onto Ruby because in the nearer future for now I'm ...
I'm creating a small app in Sinatra, and I'd like to determine my users' cities from their zip code (which they would input), the distance between them and other users' (by zip code), and possibly a heat map of the zips.
How would I do this? I've tried the geoip gem, but it doesn't seem to do what I want. Would I use an external servi...
Assuming the following:
def create_new_salt
self.salt = self.object_id.to_s + rand.to_s
end
Why is it better to use the 'self.' rather than an instance variable '@salt'?
...
Anyone know what the correct syntax to get an auth_token from Vimeo using the recently updated vimeo gem (http://github.com/matthooks/vimeo) using oAuth?
I'm trying this:
def authorize
base = Vimeo::Advanced::Base.new(VIMEO_API_KEY, VIMEO_SECRET)
redirect_to base.web_login_link("delete")
end #end method
--- get redirected to vime...