ruby

Heroku rake db:migrate fails - Missing tasks/rails

I am just diving into Heroku and have hit a bit of a snag. Whenever I attempt to create my database I am getting the following error. $ heroku rake db:migrate rake aborted! no such file to load -- tasks/rails /disk1/home/slugs/274236_54c3556_0822-55414a07-d565-459a-9412-67cc0e995790/mnt/Rakefile:10:in `require' (See full trace by ru...

Inter-programing language AND inter-server communication?

Are there protocols/solutions/messaging system that allows me to communicate between languages AND servers? Eg. I want to be able to communicate between one server running Java (or Ruby, Python etc) on the backend and one server running Javascript also on the backend. The solution I use now is HTTP REST. Are there other solutions that...

ECONNABORTED in ruby TCPserver

Hello, I'm recieving an error ECONNABORTED, and i really can't figure out, what is the cause of it. The IBM guide suggests that it is because of a timeout, but that doesn't ring the bell for me. I don't know where to start so here are few questions. a) accept() is the only thing needed to establish a connection - i mean no other functi...

Can you use semicolons in Ruby?

When learning Ruby, I noticed that in all the examples there are no semicolons. I am aware that this is perfectly fine as long as each statement is on its own line. But what I am wondering is, can you use semicolons in Ruby? Thanks in advance! ...

Save the id of autocomplete field instead of the text (Jquery autocomplete) in Rails3

Hello. I have managed to setup autocomplete field for my rails app. What I'm trying to do is to have the contents of a lookup table listed and when I have selected the lookup text for few lines I would like the id of the lookup to be saved instead of the text itself. Here is what I have done: Recipe model: class Recipe < ActiveRecor...

Best way to teach yourself Ruby?

I have a decent amount of web development and programming experience with C, C++ and several markup languages. In order to expand my knowledge I've decided to learn Ruby and I'm wondering what you guys recommend as being the best way to teach it to yourself. I took a quick browse through the books available at Amazon but nothing immediat...

Developing a Rails app in Netbeans/JRuby but deploying to Ruby (C)

I'm using Netbeans and JRuby to develop a Rails web application. But for deployment, I will be using Heroku. Since Heroku uses the Ruby-C implementation, I was wondering my use of JRuby can cause problems? Is this approach a safe thing to do? ...

Best way to make Rails view output (text) dynamic based on user properties? (similar to i18n/locales)

I need to make certain output from views dynamic based on the "type" of user logged in. Specifically, the user "type" is based on the type of business they are in and using my application, so if they are a retail store my application needs to refer to "customers", "products", "purchases", etc. whereas another type of user in a services-b...

Ruby date arithmetic error - "can't convert Date into an exact number (TypeError)"

Hi, I have the following Ruby program: require 'date' class Person def initialize(name, dob) @name = name @dob = dob end def age Time.now - @dob end def marry(someone) "Life: " + age.to_s end end fred = Person.new('Fred', Date.new(1934, 4, 16)) p fred p fred.age.to_s p fred.marry(1) But ruby 1.9.2 gives error: #<P...

Ruby Sleep in a Loop in Thread

Hello, I have the exact same problem posted here a year ago: http://stackoverflow.com/questions/1347853/ruby-loop-failing-in-thread Here the code (pretty much the same as in the topic above) class NewObject def my_funk t = Thread.new { until false do puts sleep 15 # sleeps way too much ...

parsing commandline arguments as wildcards

Hi everyone, I wrote a little ruby script using optparse. I'd like to pass a list of files to my script using optparse. I would like to add a couple of files using wildcards (e.g. /dir/*). (Background: simple script, that writes all given arguments to a single text file, separated by newline.) I tried this: opts = OptionParser.new o...

Iterating over arrays with mustache

How do I obtain a reference to the current element in the iteration? {{#my_array}} <p>{{__what_goes_here?__}}</p> {{/my_array}} I hope I am just overlooking the obvious. ...

Error when generating scaffold

I use RVM with ruby 1.9.2 and Rails. When I try to generate a scaffold for my Rails app, I get this error: <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- script/../config/boot (LoadError) from <internal:lib/rubygems/custom_require>:29:in `require' from script/generate:2:in `<main>' Is there something w...

How to tell if a table exists in DataMapper

This code is failing on the last line specifically due to the check for table_exists? How do I correctly do this in Datamapper? require 'sinatra' require 'DataMapper' DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/blog.db") class Post include DataMapper::Resource property :id, Serial property :title, String propert...

Unit testing date sensitive functions?

I am trying to write tests for a date helper class. I am wondering what is best practice for this. Here is an example in PHP. public static function get_date($offset = 0){ $date = mktime(0, 0, 0, date('m') , date('d') + $offset, date('Y')); return array( 'day' => date('D',$date), 'month' =...

How to get Ruby on Rails to generate a model using sql server 2008

Ruby version: 3.0.2 Rails: 1.9.2 OS: windows 7 DB: sql server 2008 (r2) I tried to execute the following command: rails generate model product The error I get can be seen here: pastebin.ca/1965168 I tried to follow these two sites: rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html www.lostechies....

The program 'rails' is currently not installed?

I've installed Ruby (1.8.7 via apt-get) and I installed Rails (2.3.2 via rubygems) but when I type 'rails newapp', I get this error: The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails rails: command not found When I run 'gem list' it shows rails and all of it's dependencies. Any id...

How do I debug ruby scripts?

Hi Stack Overflow, Ruby n00b here. I copied the following ruby code from the internets and made a few changes. #insert teh codes here But it doesn't work! Please help. What can I do to debug the program by myself? Thanks in advance, Andrew Grimm ...

vim auto indenting lines without semicolons in Ruby

For some reason, in vim whenever there is a line of ruby code with a function including parentheses, eg: string = gets() without a semicolon the next line is indented a level. When there is a semicolon, it works fine. Any ideas as to why this is happening and how to fix it? Also, since it will probably be requested, here is my ~/.vimrc ...

problems in a ruby screen-scraping script

Hi! I have a small crawler/screen-scraping script that used to work half a year ago, but now, it doesnt work anymore. I checked the html and css values for the reg expression in the page source, but they are still the same, so from this point of view, it should work. Any guesses? require "open-uri" # output file f = open 'results.csv'...