In my controller, I have code that looks like the following:
@mymodel.transaction do
for a in arr
@mymodel.some_method(a)
end
end
in @mymodel#some_method I could throw an ActiveRecord::Rollback exception which in the db does what it needs to do, however I then simply get an HTTP 500 and no way to catch the...
I have this list:
foo chef.rb baz
bar cucumber.rb bar
baz gem.rb foo
I want to capture all the names without .rb.
My current regexp looks like this:
/([^\s](?:.)*?.(?:rb))/i
But it captures the .rb too.
How do I capture just the base name?
Thanks.
...
Is there an easy way to initialize a cucumber folder structure like rails generators?
...
Here is my code:
case input
when "quit" || "exit"
break
end
Only "quit" works here and not "exit".
How could I have "exit" work too without having to have a new "when" line?
...
Ive been roaming around the interwebs looking for my first open-source project to contribute to - and most cool ones seem to be one-man bands on github, which I could fork - but wouldnt quite provide the code review etc. i think i want, so i can improve my python abilities.
Web.py, flask, celery, twisted etc look interesting - so far on...
Hi.
I want to have an ability to set a custom message in a model validator method to notify a user about incorrect input data.
Firstly, I set a custom validator class where I redefine the validate_each method in that way as it recommended in rails' documentation:
# app/models/user.rb
# a custom validator class
class IsNotReservedVa...
I have problems finding documentation on how to delete a document from CouchDB using CouchPotato. As fare as I know I have to set the property _deleted = true. When I want to get documents that is not deleted, I have tried to add a condition to my class like this:
view :item, :key => [:userid, :date], :conditions => 'doc._deleted === ni...
Hi all:
I must have done it in a wrong way: the records printed out are out of order, even though they are inserted into db one at a time. Here is the code:
get '/' do
db = Mongo::Connection.new("localhost", 27017).db("testdb")
@notes = db.collection('notes')
@notelist = Set.new()
@notes.find().each{|record| @notelist.add(recor...
I know many Ruby users are using Jekyll but I wonder what the benefits that will bring over RefineryCMS?
Could someone highlights the differences and pros/cons for each.
...
I'm generating a data feed on the local machine, that I want to pipe into a remote process via Net::SSH.
Something like
echo foosball | sed 's/foo/bar/g'
Just that the echo foosball part would be the data feed on the local machine.
What I'm NOT looking for is:
data = "foosball"
ssh.exec!("echo #{data} | sed 's/foo/bar/g'")
I real...
I created a top level directory called 'maintenance' in my Ruby on Rails application. There's mostly scripts there that I use for my own cleanup/project maintenance. I want to be able to load my models and activerecord so I can query them in my script. What do I have to load at the beginning of the script to get it to properly know my en...
I am building a little tool in ruby for creating directories and files based on commands that I issue it from the command line. I would like for this to work on Mac, Windows, and Linux.
I am of course new to ruby and I know how to right a simple script and call it to run from the command line. What I would like to do is be able to navig...
Hi everyone,
I've installed rvm following the official guide on rvm. I installed Ruby 1.8.7 with rvm install 1.8.7 and then set it as default with rvm 1.8.7 --default.
Now I tried to install 1.9.2 with rvm install 1.9.2(also tried rvm install 1.9.2-head). Everything goes fine until I get to the "ruby-1.9.2-head - #installing-part.
The...
What api's do you use to develop a touchscreen point of system in Ruby?
...
I'm looking from something that to replace the *parent*.
%w[apple apples].each do |w|
next if *parent*.includes? w + "s"
puts w
end
# output: apples
...
I've tried reading through various blog posts that attempt to explain alias_method_chain and the reasons to use it and not use it. In particular, I took heed to:
http://weblog.rubyonrails.org/2006/4/26/new-in-rails-module-alias_method_chain
and
http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/
I still do not see any prac...
My friends and I are working on some basic Ruby exercises to get a feel for the language, and we've run into an interesting behavior that we're yet unable to understand. Basically, we're creating a tree data type where there's just one class, node, which contains exactly one value and an array of zero or more nodes. We're using rspec's...
I found this snippet online and the purpose is to commify any number including numbers with decimals ... 99999999 => 99,999,999. I can see that it uses regex but I am confused by "$1.reverse, $2"
def commify(n)
n.to_s =~ /([^\.]*)(\..*)?/
int, dec = $1.reverse, $2 ? $2 : ""
while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3')
end
...
As the title says... Google doesn't give anything useful concerning this.
How do I set up and configure https/ssl for Sinatra apps?
How to create a https route? etc.
I have never used https for my apps before and have no experience tweaking Rack/whatever, so I appreciate detailed answers...
...
I have created a new user account on my mac and I am trying to update to the current version of ruby on it (1.9.2) from the snow leopard default of 1.8.7. Can somebody point me to tutorial or explain the best method to update Ruby on my mac from 1.8 to 1.9.2? Thanks
...