My site contains user profiles with fields such as hair and eye color.
I have been implementing lookup-table type fields with constants in my user model, ie.
HAIR = %w[shaved black blond brown red grey white bald]
EYES = %w[black brown blue hazel green grey other]
used in my views with collection_select statements to populate drop...
I have an Attendance model that allows the user to enter a starting, ending and break time, each as a ruby Time object. Each attendance also has a day (ruby Date object). I want the 'Date' elements of the times to be the same, so I override the assignment operators like this:
def startTime= (t)
self[:startTime] = Time.mktime(day.yea...
I'm a bit confused with the input's of Ruby.
Whenever I try to get input, it doesn't register the 'Backspace' key. Also, it never accepts the 'Enter' first time. I always have to push 'Enter' after my input usually 3 times before it actually inputs it.
For example,
view source
print?
1 my_var = gets.chomp
If I wanted to enter 'Hell...
Hi,
Is anyone aware of an address parser plugin for Ruby?
I might have to use one of the paid webservices but thought there might be a plugin.
Another thought is go down the NLP route where I could build up a database over time.
Does anybody use any NLP plugin for ruby?
I want to use it to logically parse and sanitise something like...
I would be happy to access any element of multi-dimensional hash-array by a shorter expression
h = {a: {b: 'c'}}
# default way
p h[:a][:b] # => "c"
# a nicer way
p h[:a,:b] # => "c"
# nice assignment
h[:a,:b] = 1
p h # => {:a=>{:b=>1}}
I realize that in this way one eliminates the possibility to have a hash key being an array.
{[...
I updated a Ruby gem, and I got that message. Does that mean something has not been installed, and the gem is missing something?
...
I'm using pict (Pairwise Independent Combinatorial Testing tool) as my tool. I'm trying to generate test cases using these constraints:
video_resolution: 352x240,352x288,640x480,704x480,704x576,720x240,720x480,720x576
video_rotate: 0,90,180,270
IF [video_resolution] IN { "640x480"} THEN [video_rotate]="90" OR "180";
but I'm having tr...
I've recently moved from C# to Ruby, and I find myself missing the ability to make collapsible, labelled regions of code. It just occurred to me that it ought to be OK to do this sort of thing:
class Example
begin # a group of methods
def method1
..
end
def method2
..
end
end
def method3
..
e...
I am newbie in RoR and creating my first project.
I have two models category and article.category has many article and article belongs to one category.I want to create cascading drop down boxes to display article.In first drop down box I want to select category which update second drop down box with articles which belong to the category....
I am trying to install a ruby gem called activeldap, however, it won't let me install it. I keep getting all kinds of errors including the Errno::EEXIST error. I added the error info below. Any ideas?
C:\Ruby\www\demo>gem install activeldap
ERROR: While executing gem ... (Errno::EEXIST)
File exists - C:
C:\Ruby\www\demo>gem install...
Hi all,
This is a continuation of a previous question. I'm having problems with this Nokogiri snippet:
>> require 'nokogiri'
>> html = 'bad<p>markup</p>with<img src="foo.jpg">'
>> Nokogiri::HTML(html).at_css('body').children.map {|x| '<p>' + x.text + '</p>'}.join('')
=> "<p>bad</p><p>markup</p><p>with</p><p></p>"
What happened to my...
If I have a string like so ..
There is a lot of white space.
And I want to remove all the unwanted space in Ruby's regex.. How do you identify white space and remove it so that there will still be at least one white space between all the words?
So far I have :
gsub(/\s{2,}/, '')
B...
Hi
I want to load a set of xml from a directory and use REXML to parse all the xml in a loop.
I cant seem to create File Object after i start reading from a directory
i=1
filearray=Array.new
documentarray=Array.new
directory = 'xml'
Dir.foreach(directory).each { |file|
next if file == '.' ...
I have built a little Web UI for Pidgin(respectively all libpurple based messengers) together with DBus and Sinatra.
It was for fun and learning purposes and now I'm looking for ideas to extend it.
Can you think of any useful applications or extensions for it?
Since I work on this project to learn something new, ideas for other techno...
I have a Ruby on Rails application that I'm working on an API for an associated iPhone application.
I have overwritten the to_json method of my Item model to return some custom information from the API request that I'll need in the iPhone app.
However, when I use the built-in rails to_json method and include my Item model as an associa...
I'm trying to point the Hudson app at the test environment in my MySQL database with Rails. Do I need to change the environment variable RUBY_ENV? If so, where do I implement this?
...
How do I create an exclusion for a array map in Ruby.
Here's what I want to achieve,
a = [1,2,3,4]
b = [5,6,7,8]
a.map.each do |x|
b.map.each do |y|
if !(x == 1 && y == 7)
puts "#{x} and #{y}"
elsif !(x == 4 && y == 8)
puts "#{x} and #{y}"
end
end
end
1 and 5
1 and 6
1 and 7 # still here
1 and 8
2 and 5
2 an...
Here is the stacktrace I get in the console:
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant ActiveRecord (NameError)
from C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
from ...
Hi. I am very new to Rails and Cucumber so this may or may not be a quick fix.
I have a cucumber scenario that loads a collection of models and then checks to see if they are all rendered to a table. Cucumber returns a result saying "Tables were not identical". What am I missing here? I have tried to add headers in the second step defin...
I'm trying to add some commit hooks to my git repo. I want to leverage Rspec and create commit message specs that will run each time I commit. I have figured out how to run rspec outside of the 'spec' command, but I now have an interesting problem.
Here is my current code:
.git/hooks/commit-msg
#!/usr/bin/env ruby
require 'rubygems'
...