Hi,
I am faced with a peculiar issue with respect to Timezone in Ruby. I want to convert the following
Sat Sep 11 15:15:00 +0530 2010
to
Sat Sep 11 15:15:00 -0400 2010
As you can notice, only the time zone has been converted and no other part has changed. How to do this in Ruby.
...
I'm trying to validate wether a Model.category equals any existing Category name
unless Category.exists?(:name => self.category.downcase)
I had to put downcase in this to ensure all of them were downcased so they could match up as strings. But its a big server hit to update the attribute before_save, and I was thinking of just matchin...
The environment:
Ubuntu 9.10 (run within VirtualBox)
Ruby v1.8.7
Redis gem v2.0.6
On irb, when I try to initialize Redis I get a RuntimeError. Here's a snippet:
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'redis'
WARNING: using the built-in Timeout class which is known to have issues when used for openi...
I'm using rspec and I'm trying to test whether or not my model y has many x. I've tried all sorts of things, including looping through the methods array, and can't seem to find a good method online. So what should I use?
...
Hi,
I need to make a basic user management system for my application using Sinatra but I'm not sure how I should think about it.
It needs to:
Register User
Login User
How should I think about it? This shouldn't be hard, I'm just very new to all this.
Thank you.
...
App will run on Heroku
Dependencies include
paperclip
haml
compass
devise
aws-s3
Reasons for or against? Any recommendation on another version of ruby?
Update
Heroku currently doesn't support 1.9.2 but it's expected to very soon based on this post. Rails 3.0 officially supports 1.9.2 (but not 1.9.1), so I decided to go ahead and ...
how do i fix this issue and get it to stop happening
CONFLICT (delete/modify): log/development.log deleted in eccc398bb3058c5c0cc9e3587aae93289597fc0f and modified in HEAD. Version HEAD of log/development.log left in tree.
I have it in .gitignore
...
I need to replace all minutes with hours in a file.
Assume a raw file like this:
120m
90m
Should change to:
2h
1.5h
...
Has anyone used both:
Boson: http://tagaholic.me/2009/10/14/boson-command-your-ruby-universe.html
and
Thor: http://github.com/wycats/thor
Thor are very popular and have more followers and contributers than Boson, but Boson looks far more powerful than Thor and the architecture is very well thought out.
In Boson you:
can add method...
I think to use Time.parse(), it needs to have a
require 'time'
but why Time.now is usable but Time.parse is not?
...
It seems that Time.parse will treat 9/12/2010 as December 9, 2010:
irb(main):012:0> RUBY_VERSION
=> "1.9.2"
irb(main):013:0> Time.parse('9/12/2010')
=> 2010-12-09 00:00:00 -0800
irb(main):014:0> Time.parse('9/12/2010 7:10pm')
=> 2010-12-09 19:10:00 -0800
I can use Regex to mess with the order and parse accordingly, but is there a di...
I am creating a rails app that is meant to be run locally and automate some of my web based tasks.
The reason for rails is that I will import data in, select a number of tasks to be completed, then tell it to start. Ideally i will keep logs of runs and keep track of what tasks were completed during specific runs.
My experience with...
If I have several objects that each have basically a Profile, what I'm using to store random attributes, what are the pros and cons of:
Storing a serialized hash in a column for a record, vs.
Storing a bunch of key/value objects that belong_to the main object.
Code
Say you have STI records like these:
class Building < ActiveRecord:...
I am new to Ruby (coming from java background) and I was wondering whats the behavior for constants in RoR applications and in general Ruby.
Are they just initialized once, like java static variables?
I am initializing a fairly big array of hash as a constant, so I want to be sure if I am doing it right?
Thanks for your help.
module...
Is there a ruby script to generate password for .htpasswd? Thanks!
...
I have a stylesheet:
a,b,c { stuff
lots of it
}
b { more stuff }
.test { even more }
I want a regular expression to break it up into each of the three parts, separating from '}' to '}' should work alright for my needs (except the first case obviously).
...
It seems strange that "2010--9-12 3:12pm" is a weak spot of Chronic Rubygem? Is there a way to make it work? (or another gem that can do it?) I also hope to find a parser that can handle 2010-09-12 3:12pm UTC or other timezones such as PDT, PST, or UTC+8 or -0700
irb(main):001:0> RUBY_VERSION
=> "1.8.7"
irb(main):002:0> require 'rub...
I'm a bit of a Linux noob trying to get ruby, rails, mysql and sqlite all playing nicely on ubuntu 10. I am getting errors, and I realized that the versions are different for sudo versus normal user!
mpw@ubuntu:~/.rvm/gems/ruby-1.9.2-p0$ gem --version
1.3.7
mpw@ubuntu:~/.rvm/gems/ruby-1.9.2-p0$ sudo gem --version
1.3.5
I have used RVM...
I want to ask users to type in a password, but i dont want the chars to appear on screen as they type.
How do I do this in Ruby?
Thanks
...
Anyone known a ruby (or at least python or java) library for kademila and emule?
...