ruby

How to freeze rake?

I have a rails-app (2.3.2) that I need to install on a server on which rake isn't installed, and on which I haven't got privileges to install gems, so I'd like to freeze the rails gem. However, I can't figure out how to do that. I've put it in the dependencies in environment.rb, but "rake gems:unpack GEM=rake" has no effect. "rake gems"...

ruby WSDL error

I'm banging my head against the wall on this error. After generating my classes out with wsdl2ruby, when I go to post a sale against the webservice I get the following error. SOAP::FaultError: org.xml.sax.SAXException: Invalid element in com.marquis.eomis.canteeninventoryandsales.resource.canteenSale.CanteenSaleContent - use...

When using Webby/Compass Integration what directory do the *.sass files go in?

I just setup Webby/Compass integration. (http://wiki.github.com/chriseppstein/compass/webby-integration) Where do I put my Compass/Sass source files, and in what directory do they get output as stylesheets? ...

Polymorphism or Inheritance in JSON with Java and Ruby

For context, we are storing most of our data as JSON strings. This works very well with Hadoop on the backend and is easy to handle in Ruby on the front end. My data types fit the natural pattern for inheritance. For simplicity, lets say I have a class Pet and a process FeedPet that feeds a pet. I also have a process WalkDog that only a...

How to convert a double to hex?

Hello, How do I convert a ruby float/double to high endian order hex with high bytes and low bytes. EXAMPLE: start with 99.0 end up with 40 58 C0 00 00 00 00 00 high bytes low bytes ...

Escape problem with hex

I need to print escaped characters to a binary file using Ruby. The main problem is that slashes need the whole byte to escape correctly, and I don't know/can't create the byte in such a way. I am creating the hex value with, basically: '\x' + char Where char is some 'hex' value, such as 65. In hex, \x65 is the ASCII character 'e'. ...

How do I use a Rails ActiveRecord migration to insert a primary key into a MySQL database?

I need to create an AR migration for a table of image files. The images are being checked into the source tree, and should act like attachment_fu files. That being the case, I'm creating a hierarchy for them under /public/system. Because of the way attachment_fu generates links, I need to use the directory naming convention to insert ...

How to set class-scope constants in ruby?

Super-beginner easy points ruby question. I'm trying to learn some ruby by programming the Project Euler problems. So I have a test class ProjectEuler_tests < Test::Unit::TestCase @solution = 123456 # Not the answer so as not to be a spoiler def test_problem_1 assert_equal(@solution, ProjectEuler1.new.solve) end end But th...

What's an example of Java functionality that I could add to a JRuby/Rails project?

This is actually two questions rolled into one. Is there a particular type of Java functionality that people are using JRuby for or is it mainly because of the performance advantage that JRuby gives versus the MRI? The reason I ask is, I'd like to add some Java functionality to a Rails project (just to show that it's possible). Idea...

How to Dynamically Determine a Method Name in Ruby

In Ruby, is there a way to determine the name of a method, akin to how the "class" method returns an object's type? For example: def example_method puts method_name end #=> "example_method" ...

Undefined method in my app. What's wrong?

Hi there! I try blocking Ip addresses in my app like this - lifeonrails.org. I already have a module in /lib and model banned_ip. Why I have this error below from views/banned_ips/index.html? ===My error:=== NoMethodError in Admin/banned_ips#index *Showing app/views/admin/banned_ips/index.html.erb where line #9 raised:* undefined me...

Ruby Connecting to SQL Server 2005

I want to connect to a sql server 2005/db with ODBC through ruby using windows authentication. I have the gems dbi-0.4.1 and dbd-odbc-0.2.4 installed. What do I need to do for a connection string? So far I haven't been able to get it to work. DBI.connect("DBI:ODBC:Data Source=#{server};Integrated Security=SSPI;Initial Catalog=#{db}") ...

Using blueprint.sass in Webby/Compass Integration

I'm following an article here: http://gom-jabbar.org/articles/2009/02/04/don-t-use-css-or-table-layout-use-sass-ad-compass more specifically the section entitled "Concrete Example of using Compass and Sass for creating a layout that people generally use tables for" The example references @import blueprint.sass Where is this file loc...

Rails: Single table inheritance and find(:all) in parent

I understand how STI works, in that I have say a Post model that contains posts on a forum and several sub-posts like 'ordinaryUserPost' and 'adminUserPost' etc. Now, I want to define the same method in each of the sub-posts, but the method would do something different in each case, eg class Post < ActiveRecord::Base end class AdminUs...

Accessing User Password: Variable Scope in Rails

I'm writing a very simple mailing system for a Rails app. I'm using RESTful authentication. It's a fairly conventional setup, where I'm sending the same email when a user signs up and when a user forgets their password. I'm just having one problem that I can't seem to wrap my head around. I'd like to use the same email template for both...

In ruby, how do I attempt a block of code but move on after n seconds?

I have a library method that occasionally hangs on a network connection, and there's no timeout mechanism. What's the easiest way to add my own? Basically, I'm trying to keep my code from getting indefinitely stuck. ...

Django or RoR

I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly. I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think ...

What are scenarios in which one would use Sinatra or Merb?

I am learning Rails and have very little idea about Sinatra & Merb. I was wondering are the situations where you would use Merb/Sinatra. Thanks for your feedback! ...

How do I handle date objects in ruby on rails forms?

I am using a rails helper that creates 3 select lists for the purpose of letting a user select a date. If I assign the helper a name, it sets all 3 select lists to have that name, and then only the last one goes through (it overwrites the previous). What I need to know is: What is the best way to take a set of 3 select lists (day, mont...

Complete web apps in Ruby without using any frameworks - how difficult? Pitfalls?

I am a Ruby noob. Has any one in this community written a Ruby app without any frameworks? (edit:My goal is to write one on my own.)Tell us about your experience. How difficult is it? Whats the lowest abstractions you used? What are the pitfalls? Thanks. ...