Hi.
I have url like this http://example.com/tag/София/new.json and I want to make get request with HTTParty, but when I do HTTPArty.get "http://example.com/tag/София/new.json" I get:
URI::InvalidURIError at /
bad URI(is not URI?): link here
Any ideas how to handle this ?
Thanks in advance,
Mitko Kostov.
...
Hi, i keep on getting ActiveRecord::MissingAttributeError errors randomly everywhere in my program. i have passenger (30 instances) running with nginx. i don't have this problem in dev. When i remove cache money it works fine in production.
this is the error msg:
ActiveRecord::MissingAttributeError (missing attribute: deposit_amount):
...
I need a method that takes a block, and performs something similar to an around_each filter for every method within the block.
For instance:
def method_that_takes_block
(@threads ||= Array.new) << Thread.new {yield if block.given?}
end
method_that_takes_a_block do
method_one
method_two
method_three
end
In this instance I wou...
I need to read metadata (song name, artist, etc.) from various audio files with ruby, mainly MP3 and Apple's AAC. I've googled and found no library that supported both formats.
How do you guys read audio metadata with ruby? I would prefer a solution with minimal dependencies possible.
Thanks.
...
Hi,
Just learning Ruby and found something bizarre (at least for ansi-c programmer).
Having Mac OS X 10.6.2, ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0],
feed-normalizer 1.5.1 and crm114 1.0.3
require 'rubygems'
require 'crm114'
require 'feed-normalizer'
#FeedNormalizer::FeedNormalizer.parse open("http://news.google.c...
I have a fragment of JavaScript that I want to add to a page, but only in the production environment. Does rails have a way to insert or conditionally include on deployment. I know I could do "if Rails.env.production?" But I'd rather not do this condition check every time the page is loaded.
...
I'm trying to figure out how to make this hack for attr_accessible to support a really common use case in my code, but really after looking at attr_acessible and ActiveRecord::Base source code for a while, still don't know where to start. I can probably figure it out after digging deeper, but first I'd like to ask if anyone else would f...
I know this seems silly, but I would like to call some of Rails' Text Helpers in a rake task I am setting up. (Thinks like the pluralize and cycle method: http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html)
How would you go about making these available in a rake task, or is it not easily possible?
...
I am writing ruby script which accesses folders on other networked machines (windows). I need to know the environment variables on that machine, how do I do this? Once I get access to the remote environment variables, It will help me know where the software has been installed.
Thanks
N.I
...
I just installed RVM and it seems the cd command is taking an extra couple of seconds, why is this happening? Is there any way to fix this?
...
How do I manually specify which test/unit test files should be run when a non-test file gets updated?
...
I'm wondering if there is a way to take an array of ActiveRecord results (or any array, for that matter) and process it in groups of 25 or so. Something like this:
User.all.each(25) do |group|
# Some code that works with this group of 25
end
I'm just looking to avoid doing multiple successive database queries. Thanks!
...
I'm trying to check if a method is defined in a module using Module.method_defined?(:method) and it is returning false it should be returing true.
module Something
def self.another
1
end
end
Something.methods has 'another' listed but Something.method_defined?(:another) returns false.
Is this maybe not working because the meth...
My web application requires 6 different cron jobs to run to update timezone sensitive data within tables at 00:01:00 of each timezone. I want to create rake tasks for each time zone. Can I configure rake tasks to be timezone aware? For e.g., can I do that following in a rake task:
namespace :db do
task :update_EST_records => :env...
Hi, so I'm setting up some models and they are based off of 2 abstract base classes (or rather they used to be classes). After running into a lot of trouble with Datamapper's handling of STI for my use case, which appears to be an open bug on their lighthouse page, I decided instead to just do modules to define all the properties to keep...
Is there a way of generating a string that would match a regular expression in Ruby
e.g.
regex output
^\d{6}$ 875914
^\d{3}-\w{2} 584-AS
...
After developing an awesome app on my local machine without any consideration of how it would perform on my host, I have run into a terrible issue. I am serving files (.pdf & .zip) through rails send_file so that I can log statistics. The only problem is that when two (or more) files are downloaded simultaneously, a new ruby dispatch.fcg...
I have a number of file tasks in my Rakefile which look like
file 'task1' => 'dep' do
sh "some command"
end
There's also
task :start => :next
task :last => :dep2
I was wondering if there was a way of rescuing it on the top level, i.e. to say
begin
task :last => :dep2
rescue
# do something
end
rather than in every file tas...
I have a title doc.at('head/title').inner_html that comes out & and it should be &.
My original document is:
<head><title>Foo & Bar</title></head>
but in comes out as the following:
>> doc = Nokogiri::HTML.parse(file, nil, "UTF-8")
>> doc.at('head/title')
=> #<Nokogiri::XML::Element:0x..fdb851bea name="title" children=#<Nokogiri...
I want to write a function that allows users to match data based on a regexp, but I am concerned about sanitation of the user strings. I know with SQL queries you can use bind variables to avoid SQL injection attacks, but I am not sure if there's such a mechanism for regexps. I see that there's Regexp.escape, but I want to allow valid re...