ruby

Rails: Undefined method 'to_sym'

I'm getting the following error in my deployed Rails 2.3.5 application: NoMethodError (undefined method `to_sym' for nil:NilClass): My local testing install of the application, which uses Sqlite, doesn't get the error, but my deployed app running Mysql does. The only other difference between the two is I'm running Ruby 1.8.7 on my loc...

Very odd issue with Ruby and regex

I am getting completely different reults from string.scan and several regex testers... I am just trying to grab the domain from the string, it is the last word. The regex in question: /([a-zA-Z0-9\-]*\.)*\w{1,4}$/ The string (1 single line, verified in Ruby's runtime btw) str = 'Show more results from software.informer.com' Work ...

String/Range comparison problem

This make sense for things like : irb(main):001:0> ["b", "aa", "d", "dd"].sort => ["aa", "b", "d", "dd"] But doesn't for : irb(main):002:0> ("B".."AA").each{ |x| print "#{x}," } => "B".."AA" should produce : B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,=> "B".."AA" but "B" > "AA" => true Unlike "B".."BA" ("B" > "BA" => fa...

Mass assignment on construction from within ruby.

Possible Duplicate: Idiomatic object creation in ruby Sometimes it's useful to assign numerous of a constructed arguments to instance variables on construction. Other than the obvious method: def initialize(arg1, arg2, arg3) @arg1, @arg2, @arg3 = arg1, arg2, arg3 end Is there a more concise idiom for achieving the same re...

Do any Ruby RSS parsing libaries support MRSS?

I'm attempting to parse Media RSS feeds that contain media:* elements, but it seems as though all of the standard RSS parsing libraries for Ruby only support enclosures, not MRSS elements. I've tried: SimpleRSS RSS::Parser Syndication:RSS::Parser Ideally, I'd like something that makes it simple to extract elements such as media:th...

Ruby on Rails, mysql column type :text, What class is this as a ruby object?

你好, When a column in mysql table is typed :text, how is this then treated in Ruby. In other words, what is the class? Is it a string? ...

Ruby regular expression using variable name

Is is possible to create/use a regular expression pattern in ruby that is based on the value of a variable name? For instance, we all know we can do the following with Ruby strings: str = "my string" str2 = "This is #{str}" # => "This is my string" I'd like to do the same thing with regular expressions: var = "Value" str = "a test V...

Rails routing - custom routes for Resources

Hello guys, I'm building currently one Rails app and I'd like to stick to all those fancy things like REST and Resources, but I'd like to customise my routes a little. I want my GET route to be little more verbose - the app I'm creating is a simple blog, so instead of GET /posts/1 I'd prefer something like GET /posts/1-my-first-post. An...

Accessing values in a has_many :through join table

I've got users who are members of groups through a membership join table, and one of the attributes of that join table is "administrator". I'm trying to do a check inside of a group's member view, looping through each member to see if they are an administrator. In the view I tried the following: for user in @group.users if user.admin...

java.net is moving to Jruby???

There is a post on http://kenai.com/ from Oracle's Ted Farrell which has an interesting statement: We are in the process of migrating java.net to the kenai technology. Does this mean java.net will be powered by Jruby on rails?? ...

uninitialized constant with rails friendships

Hi. I'm new to rails and getting the following error: NameError in FriendshipsController#create uninitialized constant FriendshipsController this also shows up: {"authenticity_token"=>"eQvv3flATE+P1TEErOWP/6fM8dEOIBxltobCxtM/F18=", "friend_id"=>"32"} When I click on the "Add Friend" Link on my users show page. I am following th...

How do I troubleshoot errors in Ruby on Rails?

I am trying to get a Rails app working on my web host. Using CPanel, I can create a rails app and I can access the index.html (Welcome aboard) page from my browser. But when I click on "About your application’s environment", it says "We're sorry, but something went wrong." I don't have access to any files on the webserver outside of...

Working with date and time

I have a UTC date of Tue, 16 Feb 2010 03:12:02 UTC +00:00, for example. I want to add 168 hours to this date to get a future UTC date. What's the best way to do that? ...

invalid chars filter for file/folder name? (ruby)

My script downloads files from the net and then it saves them under the name taken from the same web server. I need a filter/remover of invalid characters for file/folder names under Windows NTFS. I would be happy for multi platform filter too. NOTE: something like htmlentities would be great.... ...

Is there a Ruby database migration gem, that helps you move content from an old structure to a new structure?

Hi there, Are there any Ruby gems/libraries that help you migrate from an old DB structure to a new structure? ActiveRecord migrations do a good job keeping track of a new db structure, but I wonder if there's something that helps you migrate an entire legacy db to a new structure: transfer_from(:source_table => 'person', :destination_...

Ruby create an object from a query string

I am using a new Rails project & an old established Oracle db using adapter: oracle_enhanced. Would like to be able to have dynamic searches against the db depending upon what info/field(s) is available to search against. I am trying to get from http://www.abc.com/order/show?acct_num=a123&po_num=789z and create an object such as...

Time-limited computation in Ruby

I want to run a task in Ruby for up to (say) 10 seconds, and kill that task if it has taken longer. This is to prevent hanging of an external process. What's the best way of implementing this? In particular, how would I write the function for_up_to_10_seconds below? loop do for_up_to_10_seconds do # something end end ...

cannot make ffmpeg gem work on windows (ruby)

I installed ffmpeg on my windows machine with no error message using gem install ffmpeg. hm so did I actully install ffmpeg-ruby from here? require 'rubygems' require 'ffmpeg' video = FFMPEG::InputFormat.new('alligator.mp4') gives me 'NameError: uninitialized constant FFMPEG" Does anybody have working ffmpeg ruby gem under windows t...

Sad story - git+ssh+ruby

Problem: i need to verify git repo properties (ssh key,repo url) in ruby solutions: 1) write ssh key into ~/.ssh/id_rsa file and execute git clone command with repo url property - easiest way cause race conditions when multiple users trying to check theirs repos. 2) write key into any file and link server and key in ssh.config file...

Ruby Gem package manager failing with Gem::GemNotFoundException

I haven't used Ruby for a while on my Mac. Obviously something has changed in my environment as gem is no longer working as it should. Some info from my machine, running OSX 10.5.8: % gem --version 0.9.0 % gem env Rubygems Environment: - VERSION: 0.9.0 (0.9.0) - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8 - GEM PATH: ...