Hi,
Let's say I have a rakefile like this:
file 'file1' => some_dependencies do
sh 'external tool I do not have control over, which sometimes fail to create the file'
???
end
task :default => 'file1' do
puts "everything's OK"
end
Now if I put nothing in place of ???, I get the OK message, even if the external tool fails to ge...
in ruby you can do conditional block like so
block do |n|
puts n
end if foo == bar
which would translate into erb as
<% block do |n| %>
<%= n %>
<% end if foo == bar %>
is there a way to achieve this in haml other than wrapping the block in a condition?
...
On Railcasts I have noticed a very interesting feature 'Go to symbol' window. It work like Command-T but shows available classes and methods in current file. How to get it in vim?
...
Part 1:
I have a call to layout(:default){|path,wish| wish !~ /rss|atom|json/} but requests to /foo/bar.json seem to think wish is html and uses the layout anyway. How can I fix this?
Part 2:
I want to route /path/to/file.ext so that it calls the method to on the controller mapped to /path and uses ext when formulating the return. Is ...
We're using the OpenPGP gem (http://openpgp.rubyforge.org/) to PGP-
encrypt an XML file for submission to a third-party for processing.
The prob is that when encrypting, we get errors like the following:
RangeError: 1502 out of char range
from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/
openpgp-0.0.3/lib/openpgp/buffer.rb:1...
While installing ruby-1.9.2-p0 with rvm on an updated Ubunutu x86_64, I keep getting an error in `merge': can't convert String into Hash (TypeError). All apt packages in rvm notes and those found in the rubygems manual have been installed. I believe the error is resulting when RVM is attempting to install rubygems.
I also get the same e...
Developing a little survey webapp, ran into problem that deals with ranges for rating type questions.
So a rating's range could be:
1..10
-5..0
-5..5
'a'..'z'
'E'..'M'
and so on
The range is stored as a pair of varchars in database (start and end of range). So range always starts off as a string input.
What is the best way to take t...
I'm trying to convert someone's Ruby code into my Python code. The originally developer is no longer with us and I don't know Ruby. Most of his code is easy enough to follow, but some of the following syntax is tripping me up.
Example:
myTable = ''
myTable << [ 0, 1, 0, 0, 0, 300].pack('vvvvvv')
...
I am trying to install the mysql2 gem via the Bundler, but it keeps dying with the following error:
** executing command
/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb:483:in 'rescue in block in build_extensions':
ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/home/cc...
FireWatir
I recently started using Firewatir for testing, I followed all the required steps while installing firewatir but I am not able to run the script.
Here is the information from my local machine
ruby version: ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32]
gems installed:
C:>gem list
* LOCAL GEMS *
activesupport (...
When I read that people run phusion as the web server, and they allocate x amounts of ram per instance, what does this mean?
Instance of what? Isn't phusion the web server?
Or are they running x instances of phusion, each on their own ports and round-robinning?
...
I am using Soap4r and HTTPClient to interact with a Webservice. The Service only accepts requests which have been digitally signed with an X509 certificate. I have gone through the steps of generating a private key, getting the certificate request ( CSR ) and getting the actual certificate from the authority ( the company hosting the w...
I have been looking into rails file upload tools and the ones that seemed the most appealing and interesting to me were carrierwave and dragonfly.
From looking around it seems like carrierwave takes the more traditional style where you can process the file on save whereas dragonfly is middleware so it allows you to process on the fly.
...
When I write Java in Eclipse, I can point to pretty much any declaration or method invocation and instantly get the relevant Javadoc for the class or function I'm interested in. I guess it's spoiled me a bit -- rarely do I have to poke through the API documentation by hand, and frankly it's a nice feature to have.
I've been doing Ruby ...
I have a relationship in my ActiveRecord based model that looks like:
belongs_to :foo
My model should always have foo defined in it for it to be valid. My question is, when using validates_presence of, which one is the appropriate one to use:
validates_presence_of :foo
or
validates_presence_of :foo_id
Assuming here of course, th...
Due to circumstances beyond my control, my production Camping site appears at mysite.example.com/mysite. I'm pretty sure this is a common Apache / Passenger configuration issue, and I'm not interested in how to fix it right now because the server is out of my control. Suffice to say, the controller for "/" points there and I can't chan...
Hi,
I am displaying a large number of vehicle records (120k+), each record has an engine size for that vehicle. The engine size can either in one of two formats:
"1.8"
OR
"1995" #cc's
If the engine size is saved as a 4 char string I want to abbreviate in the view, to the nearest 100th - for example "1995" should get displayed as "2.0...
Im setting up a simple checker program thing. For now, its extremely simple and is jsut checking integers. I dont think the regular expressions are wrong, but I am new to ruby.
testing out the auto-regex
def createRegexClosure(re)
reg = Regexp.new(re)
return lambda { |t|
return reg.match(t)
}
end
pr...
I'm following the guide at, http://guides.rubyonrails.org/getting_started.html
Ruby 1.9.2p0
Rails 3.0.0
But I'm locked at 6.2/6.3, when I try to add the;
<%= link_to "Species", species_path %>
I get the error (I switched the Post example to Specie);
ActionController::RoutingError in Home#index
No route matches {:act...
I insalled jruby, and when I type:
> bin/jruby -S rails myapp
I get:
bin/jruby -S rails myapp -d mysql
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/snad/dev/jruby/jruby-1.5.2/bin/jruby
-d, [--database=DATABASE]...