How do you use ARel's #as method?
If you build a projection like this: t = Arel::Table.new(:projects) ps = t.project(t[:id].as(:snark)) How do you get the result column that's named :snark? ...
If you build a projection like this: t = Arel::Table.new(:projects) ps = t.project(t[:id].as(:snark)) How do you get the result column that's named :snark? ...
Hello, I've been a PHP Developer for a few years now and I've recently been interested in learning Ruby & Rails but I've found a lot of the resources I've found seem to be dated and not for Rails 2.0 or Ruby 1.8.6 etc... can anyone point me in the right direction? I'm running OSX 10.6 with the default ruby & rails installation. Thanks!...
I have cases where user-entered data from an html textarea or input is sometimes sent with \u00a0 (non-breaking spaces) instead of spaces when encoded as utf-8 json. I believe that to be a bug in Firefox, as I know that the user isn't intentionally putting in non-breaking spaces instead of spaces. There are also two bugs in Ruby, one o...
I am attempting to parse, not evaluate, rails ERB files in a Hpricot/Nokogiri type manner. The files I am attempting to parse contain HTML fragments intermixed with dynamic content generated using ERB (standard rails view files) I am looking for a library that will not only parse the surrounding content, much the way that Hpricot or No...
I want to start up my Rails development server like this: script/server OFFLINE_MODE=1 and have a method in application_controller.rb that checks for the presence of that constant: helper_method :offline_mode? def offline_mode? defined?(OFFLINE_MODE) ? true : false end so I can hide stuff in my app when I'm coding without access ...
How can I mock an array's sort expect a lambda expression? This is a trivial example of my problem: # initializing the data l = lambda { |a,b| a <=> b } array = [ 1, 2, 3, 4, 5 ] sorted_array = [ 2, 3, 8, 9, 1] # I expect that sort will be called using the lambda as a parameter array.expects(:sort).with( l ).returns( sorted_array ) #...
I have a Sinatra Application enclosed in Sinatra::Base and I'd like to run some code once the server has started, how should I go about doing this? Here's an example: require 'sinatra' require 'launchy' class MyServer < Sinatra::Base get '/' do "My server" end # This is the bit I'm not sure how to do after_server_running ...
What's a dev blog that continues the innovative quality of PJ Hyett's and Chris Wanstrath's discontinued Err The Blog? Ruby or otherwise. http://errtheblog.com/ ...
Is there a ruby way to digitally sign email messages via S/MIME? Our group uses PKI and our users are conditioned to expect digital signatures for important messages. I know I can invoke the openssl command line tool: openssl smime -sign -signer $CERT_FILE -passin pass:$CERT_PASS -in $UNSIGNED_MAIL -out $SIGNED_MAIL -certfile $CERT_...
Hi guys, In Ruby language, how can I get the number of lines in a string? ...
I'm creating a video game. It has Characters & Items. Since I want Characters & Items to each have a name, should I make another class called NamedObjects with just a name field and have Characters & Items extend that? Or is that going overboard? ...
Hi All, Sorry for this question but after spending 1-2 hours on how to read xml, i thought posting it on forum will be better. So i get a complex (very large)xml response from the plugin trackify. i want to read some values from it so i convert it into hash and then read it as follows For ex:- to read city @tracking_info['TrackResponse...
I want to scrape text data from a windows application to do additional processing using existing ruby code. Would it be possible to scrape the data as it is updated in the windows application using Ruby and where do I start? ...
I have a class with a custom each-method: class CurseArray < Array def each_safe each do |element| unless element =~ /bad/ yield element end end end end And want to call different block methods, like "collect" or "inject" on those iterated elements. For example: curse_a...
Everything was working fine , until we decided to upgrade ruby to 1.8.7 from 1.8.6, and thats when all hell broke loose. When we compiled Ruby 1.8.7 from source it got installed into /usr/local/bin and Ruby 1.8.6 stayed in /usr/bin. Currently, we've uninstalled ruby 1.8.6 and by some stroke we deleted the ruby 1.8.7 files from /usr/loca...
require 'rubygems' require 'mysql' db = Mysql.connect('localhost', 'root', '', 'mohit') //db.rb:4: undefined method `connect' for Mysql:Class (NoMethodError) //undefined method `real_connect' for Mysql:Class (NoMethodError) db.query("CREATE TABLE people ( id integer primary key, name varchar(50), age integer)") db.query("INSERT INTO peop...
Good afternoon, I'm learning about using RegEx's in Ruby, and have hit a point where I need some assistance. I am trying to extract 0 to many URLs from a string. This is the code I'm using: sStrings = ["hello world: http://www.google.com", "There is only one url in this string http://yahoo.com . Did you get that?", "The first URL in t...
Hi, How would I invoke an external application through the RubyCocoa bridge? I read something about NSTask, yet I have no idea how this should be translated in RubyCocoa. My goal is to have an IB_action to trigger a method which will run a terminal application with some parameters, i.e. ls -p $mydir, where mydir comes from an IB_outlet ...
Hi, I've a file in the config directory, let's say my_policy.txt. I want to use the content of that file in my controller like a simple string. @policy = #content of /config/my_policy.txt How to achieve that goal, does Rails provide its own way to do that? Thanks ...
I want to set default cookie domain for my application to ".mydomain.com" to allow cookie session be preserved across subdomains. There are many places showing how to do it in Rails 2.x but these solutions doesn't work for Rails3. Anyone know how can I set it? ...