ruby

How to quickly initialize ruby project development environment?

How to specify gem dependencies in a way that user with only ruby, rake and rubygems installed could issue a single rake command to install all the dependencies required? Is it possible to use the same dependency specification when building gem with GemBuildTask? ...

Which ruby ORM framework to use in a standalone ruby app?

I would like to use postgresql with foreign keys to define relationships in data so that other platforms/apps would also be able to easily use the same database. Having some kind of ruby DSL to define database schema with migration support would also be great. Which framework would you recommend for me? Is there some kind of framework f...

Strip/replace spaces within a string

Give a string "5 900 000" i want to get rid of the spaces using gsub with a following pattern: gsub.(/\s/, ''), but that doesn't seem to work. Nor the gsub.(' ', ''). Any ideas guys (ang girls) ? ...

Ruby on Rails: Problem installing gitorious in Ubuntu 9.0.4

I seem unable to install Gitorious. I am trying not to install Ruby Enterprise Edition, but apart from that I have been following the instructions for Ubunut (there were some errors but I have gotten around those). I have installed a number of missing packages and gems, but now I am stuck when I try to migrate the database. I get the fol...

RoR: to_json on an array of hashes

Hello all, I have an array of hashes in a Rails action which i return to client in json format: {"msg": "Got report data.Check 'report' json object. ", "success": true, "reports": "[{\"total_transfers\": 0, \"total_keywords\": 0, \"keyword\": \"plum\", \"total_duration\":1464.0, \"total_calls\": 22, \"total_sms\": 0, \"avg_duration\": ...

Overriding ApplicationHelper?

There is an ApplicationHelper in an engine we're using that looks like this: module ApplicationHelper def page_title() # ... end end This gets called by a number of views in the engine. I'd like to override this method in my application to provide a different default title. How do I do this? Simply defining my own ApplicationH...

Getting the current request in rails from a file in lib/

I've put all of my user-authentication code in one place, namely lib/auth.rb. It looks like this: lib/auth.rb module Admin def do_i_have_permission_to?(permission) # Code to check all of this goes here end end I include this module as part of the application helper, so these functions are available in all the views: appli...

Debugging RubyCocoa in Xcode

I have an Xcode project of RubyCocoa and need to debug it. Leopard already comes with Ruby installed. I read that there is a need to install a debug-ruby. My question is: RubyCocoa site says that in order to debug Ruby a debuggable version should be built in the ruby source directory. Where should I build it on Leopard? Thanks, Nava ...

show error message of validation from another controller

I have form in views/users/show.html.erb <% form_for [@user,Wall.new] do |f| %> <%= f.error_messages %> <p> <%= f.label :message %><br /> <%= f.text_area :message,:rows=>4 %> </p> <%= f.hidden_field :sender_id,:value=>current_user.id %> <p><%= f.submit "Submit" %></p> <% end %> and I have this validation method in Models/wall.rb vali...

HABTM association associated to single table inheritance help!

hi all I have a product model that has many sections and a section can belong to many products. The section model has subclasses as features, standardAccessories and OptionalAccessories in a STI. Each having field title, body, image url and (optionalAccessories) has price. my models are class Product < ActiveRecord::Base has_and...

Does RadRails have keyboard triggers (code templates) as a shortcut for writing repetitive code?

One of the things I like about Netbeans Ruby development is keyboard triggers. For example, if you are in an erb template and you type: licai After you hit the tab key, this text gets replaced with: <%= link_to "${1 default="link text..."}", :controller => "${2 default="items"}", :action => "${3 default="edit"}", :id => ${4 defau...

What's the best way to pass in the domain name of your rails server for mailing?

I have an app that has is up in a few environments i.e. (development, staging, beta, live) What's the best way to pass in an app's domain name when sending mail, to allow for different domain names depending on the server? My first thought is to add something in the respective environment.rb files for each one, so config/environments/b...

Using Perl, Python, or Ruby, how to write a program to "click" on the screen at scheduled time?

Using Perl, Python, or Ruby, can I write a program, probably calling Win32 API, to "click" on the screen at scheduled time, like every 1 hour? Details: This is for experimentation -- and can the clicking be effective on Flash content as well as any element on screen? It can be nice if the program can record where on screen the click...

Validation of XML file against XSD in Ruby

Hi I'm trying to validate the following XML against a XSD schema using Ruby. It simply won't work, stops with an error message telling me Error: Element 'request': No matching global declaration available for the validation root. Maybe it's the namespace? I'm desperate. Please help. Thanks! XML: <?xml version="1.0" encoding="UTF-...

How can I set the RAILS_ENV in a Windows console?

On Linux and OS X, I'm accustomed to running Rake tasks in specified Rails "environments" by doing this: $ export RAILS_ENV=monster_island ; rake monsters:destroy_all How can I do the equivalent if I'm running the task on Windows XP in a Windows console? ...

(Ruby,Rails) Multiple simultaneous drag-and-drop items...?

Hi All, I'm looking for a mechanism in Rails by which to facilitate multiple drag-and-drop items simultaneously. Basically I want to select multiple and drag. Obviously I'd prefer to stick with standard HTML items and javascript, but if this isn't possible I'll consider a straightforward Flash implementation. Thoughts? ...

Overriding module in Ruby?

I have this code in vendor/{engine}/app/helpers/application_helper.rb: module ApplicationHelper def application_title() "Foo" end def other_method() # ... end end And this in app/helpers/application_helper.rb: module ApplicationHelper def application_title() "Bar" end end I get "Bar" as expected when callin...

What's the best tutorial to start learning Ruby?

Possible Duplicate: What is the best way to learn Ruby? There's tutorials on Rails but it's hard to find good on-line tutorials for Ruby. What's your favorite one? ...

deploying ruby on rails applications on solaris 10

Is there anyone out there that is currently deploying rails applications on a solaris 10 box? If so can you give me a brief run down of what you had to do to get it up and going? I am a web developer and I am working in a closed environment where they are using sun solaris servers, all of which are for internal use only behind firewall....

Rails migration management - best practices ?

What are best practices for migration management? For instance, when debugging a migration, do you edit the original migration or add an edit migration before committing to the repository? Thanks! ...