I have a Rails named_scope which is using a condition to pull specific days of the week from the table like so:
:conditions => [ 'EXTRACT(DOW FROM bookdate) IN (?)', (1..6).to_a ]
The 1..6 date range will be a variable depending on the dates the user wants,
Which produces this SQL
(EXTRACT(DOW FROM bookdate) IN (1,2,3,4,5,6)
My pr...
I'm trying to make elliptic curve digital signature with Ruby EC class, but my Objective-C validation code (made with libcrypto ECDSA_verify()) fails to recognize it.
#!/usr/bin/env ruby
require "rubygems"
require "base32"
require "openssl"
msgHash = OpenSSL::Digest::SHA1.digest("Message text")
key = OpenSSL::PKey::EC.new("secp160r1")...
Hi, using OS X 10.5.6
I installed fxruby using
$sudo port install rb-fxruby
As suggested in the book.
It works, my hello world program worked correctly.
Now, though, other code that I have written is broken, whenever I try to use any code that relies on a gem, it does not work. When I do
$ruby -e "require 'rubygems'"
in my code, i...
I'm not going to make this into a Rails vs Framework X discussion, there's plenty of those already. After seriously contemplating what framework I'm going to use for my next deployment, I decided it's very difficult to pass up the out of the box REST exposure Rails gives you for minimal work back. This is something that requires slightly...
what could be the possible reason that my ruby script is not being called successfully?
note that when i manually execute the post-commit script like so:
/var/svn/eweds/hooks/post-commit /var/svn/eweds 151
works just fine, the way my ruby sript is called in the post-commit script is like this:
ruby /home/pmind/public_html/eweds/scri...
params[:hello] # => "Some params value"
hello = params[:hello]
hello.gsub!("whatever","")
params[:hello] # => ""
I don't understand, can someone please explain why the params[:hello] gets modified by the gsub! ? I expected the hello string to be modified, but not the params hash.
...
A few years ago a friend of mine suggested I learn Ruby. I've since learned PHP and VB.NET but I never got around to Ruby. Where can I start with Ruby?
Also, as a side note:
What is Ruby primarily used for? How would you describe it in comparison to PHP? Python? VB?
EDIT:
How can I get it set up on Ubuntu 9.04? Vista or 7 Home Prem?...
I have csv file with 14 columns and I want to sort it in ruby by 6th column then by 2nd and then by 11th column.
There is nice method .sort_by but it works only for two columns, doesn't it. And array_of_arrays.sort_by {|e| [e[2], e[0],e[1]],} doesn't work.
so let's say in the sample below I want it to be sorted by 3rd,1st,2nd columns
...
I like the rake task structure and rake utilities.. I want to create a script that can do many things, and rake seems the logical choice.
I want to know how can I make it look like a regular script:
./myscript.rb cake:bake
as opposed to
rake -f myscript.rb cake:bake
any idea? Of course, rake must still be installed etc.. simply to ...
Argh!
Everything has been totally fine, then all of a sudden I started getting this error when I was doing a 'rake db:migrate'
And I get the same thing when I try to restart the rails server.
rake aborted!
undefined method 'form_for' for module `ActionView::Helpers::FormHelper'
Confirmation that I'm running a current version:
mm-MacBo...
Ok this worked:
Student.transaction do
if @student.test!
y = @student.rooms.first
book = Book.find(:first, :conditions => ["room_id = ?", y])
It's strange. I wanted to get the last record not first, yet it thought first was the last and worked. Not sure why.
...
Here's my controller:
class MyController < ApplicationController
include MyHelper
def index
get_list_from_params do |list|
@list = list
respond_to do |format|
format.html
format.xml { render :xml => @list }
format.json { render :json => @list }
end
end
end
end
...the helper tha...
I am using the ruby smpp library to send/receive SMS. Right now we are sending messages to two different servers, using the ruby-smpp library. One of them works perfectly, but the other one sends multiple DELIVRD confirmations for each messages. And by multiple I mean hundreds of confirmations per message in some cases.
Does anyone know...
this is what I want to do.
a href="javascript:sayHello('an nyung')"> click here /a
this code is in a server side.
and I wanna to call this link from a client side by using ruby.
is there any way to do this?
...
On runtime, my code often come into an undefined method error for the method mate. As far as I can figure, a Person somehow slips through the cracks sometime along the code's exucution, and manages not to have an allele assigned to it.
Code (disclaimer, not the best formatted):
class Allele
attr_accessor :c1, :c2
def initialize(c1...
I've inherited a large pile of Ruby code that's, frankly, close to impossible to understand for a mortal like myself. It's actually Rspec unit test code, but the structure is "highly unusual" to put it nicely.
What I'd like to be able to do is run the code, and have the following information logged somewhere:
every method that gets i...
I am trying to call the standard Win32 API functions to get file version info, using the win32-api library.
The 3 version.dll functions are GetFileVersionInfoSize, GetFileVersionInfo, and VerQueryValue. Then I call RtlMoveMemory in kernel32.dll to get a copy of the VS_FIXEDFILEINFO struct (see Microsoft documentation: http://msdn.mic...
How can I have a block execute whenever an instance of a DataMapper class is a created, and another before it is destroyed?
...
I'm attempting to build my first ruby gem and all seemed to go well until I attempted to install the gem. I'm using RVM so no need for 'sudo gem install' here.
First I attempted to do the following:
jim:~/Desktop/spectest \ [git:master]
→ rake manifest
(in /Users/jim/Desktop/spectest)
Cleaning
- pkg
rm -rf pkg
Building Manifest
Man...
Within my Rails application, I'd like to generate requests that behave identically to "genuine" HTTP requests.
For a somewhat contrived example, suppose I were creating a system that could batch incoming HTTP requests for later processing. The interface for it would be something like:
Create a new batch resource via the usual CRUD met...