ruby

ActiveSupport Inflection library for Past Tense in Ruby?

Is there a past tense library for ruby, to convert words into the past tense? ...

Association not finding created objects in tests

I have following models in my app: class Game < ActiveRecord::Base has_many :players has_many :villages, :through => :players end class Village < ActiveRecord::Base belongs_to :player end class Player < ActiveRecord::Base belongs_to :game has_many :villages before_create :build_starting_village protected def...

Specifying a different model than the controller name suggests

Guys, I've got a controller called "ResourcesController", but its really managing the CRUD for two different models. I don't actually have a model called Resource, so the controller is balking that it can't find it. Is there a way I can inform the controller which model I'll be working with so it doesn't freak out? The error that is ...

Authenticate user through GitHub API using Ruby?

I have to authenticate user through GitHub API using Ruby to be able to create a private repository. The manual http://develop.github.com/p/general.html shows how to do it with curl. Could someone show me how to do it with Ruby gem like: rest-client http://github.com/pengwynn/octopussy or octopussy http://github.com/pengwynn/octopus...

Getting a list of related models in rails

Suppose I have an object Person, which has_many :foos and :bars. Given an instance, p (p = Person.new), how do I programmatically determine what relationships are available? i.e. p.some_method => ["foo", "bar"] ...

Building a news feed for my Rails site. Any pointers?

I have a Rails site. I want to create a news feed. Does anyone have any pointers/advice/caution with this? What are some common schemas? We're using ActiveRecord+MySQL (at least for now), should that be sufficient, or is NoSQL the way to go? ...

Ruby - Remove all other characters from a String

I have a string h2#test- ruby is so awesome, blah, blah, blah. I want to have #test to be the only characters left. is there a way in ruby to run a Regular Expression that removes all other characters? ...

Appending heredoc string after a specific heredoc string if file doesn't contain that heredoc string?

I want to append a heredoc string after a specific heredoc string if file doesn't contain it already. Eg. Here are 2 files: # file1 Description: I am a coder Username: user1 Password: password1 # file2 Description: I am a coder Username: user2 Password: password2 Address: Email: [email protected] Street: user street 19 A I wan...

Benefits of using Ruby FileUtils instead of Bash commands?

What are the benefits of using FileUtils methods http://ruby-doc.org/core/classes/FileUtils.html than the equivalent Bash commands? ...

How to create subcommands for Ruby programs?

I am writing a Ruby CLI (Command Line Interface) program and I would like to be able to call subcommands similar to what rails does when you call rails generate ... or rails server etc. Can anyone point me in the right direction on how to do this? ...

Create array without declaring it first - Ruby

Howdy! I'm sorry if this question is a dumb one, but I must ask. In PHP, we can create a array without declaring it first, althought it isn't considered good pratice. Exercising my newly-knowledge of Ruby, I was writing a code to list the files inside a directory and sort them by their extensions. To do this, I started a loop to put the...

Append content after a specific string in a file?

I have this file: # file.txt My first name is Foo and my last name is Bar. I live in Baz. I want to add: My number is Baz. after: My first name is Foo and my last name is Bar. So the result will be: My first name is Foo and my last name is Bar. My number is Baz. I live in Baz. How could I do this in Ruby? ...

Match a content with regexp in a file?

I want to see if a text already is in a file using regexp. # file.txt Hi my name is Foo and I live in Bar and I have three children. I want to see if the text: Hi my name is Foo and I live in Bar is in this file. How can I match it with a regexp? ...

Rails 3: alias_method_chain still used?

I was just reading about Gems/Plugin development for Rails 3 and ran across this post that says that alias_method_chain is no longer used. I can see the method is still there in activesupport-3.0.0/lib/active_support/core_ext/module/aliasing.rb. Should I still be using alias_method_chain in Rails 3? Is this still reflective of the best...

Forge To: email header with ActionMailer.

I'd like to send an email from my rails3 application to a set of users but have a dummy To address. For example: To: Some Entity From: Some Entity Bcc: [email protected], [email protected], [email protected] However, since ActionMailer leaves it up to the MTA to parse out the email addresses to send to (as opposed to passing an explicit re...

Can anyone suggest me good links or tutorial for rhomobile ?

I want to learn rhomobile to make cross platform mobile applications.. Can anyone provide me good links and tutorials to start up with rhomobile ?? What dependencies i need to install to work with rhomobile on windows ?? ...

Ruby zlib::Gzip not working properly

I was in the middle of creating an inport/export system that could encode a costume data structure in an xml tree and then read it back and recreate the object. I got the xml part to work fine but when I discovered that the xml file was 1.5mb when the original ruby::Marshal file was only 105kb I decided that it would be a good idea to co...

Cannot find a class

You can use Octopussy like this: Octopussy.user "my_account" But I cannot find the "user" method in the API documentation http://rdoc.info/github/pengwynn/octopussy/master/Octopussy According to the documentation that module is extended by SingleForwardable. That module has to contain the method "user" but I cannot find that module....

Rails 3. Creating a production database

Hi. How can I create a production database in Rails 3 and load a schema to it? I tried the following approaches... I. rake db:create Rails.env='production' Rails 3.0.0; Sqlite3 3.7.2. ...

Ruby on Rails source code security / obfuscation

I'm just getting started with Ruby on Rails development and I have a question concerning source code "privacy". From what I know so far (i have not done a deployment yet, only used RoR in a local development environment), that when a RoR application is deployed, all the source code is "visible" on the server? How can I protect my code;...