In Ruby, getoptlong destructively parses ARGV. Is there a way around this?
I need to invoke getoptlong multiple times, but after the first time ARGV is empty. ...
I need to invoke getoptlong multiple times, but after the first time ARGV is empty. ...
What does ::Base part mean in Person < ActiveRecord::Base class declaration? I'm new to ruby and from what I've gathered so far, Person < ActiveRecord should be used. Thank you. ...
Hello, I'm new to ruby and started to create my *nd toy app. I: Created controller 'questions' Created model 'question' Created controller action 'new' Added 'New.html.erb' file in erb file I use form_for helper and and new controller action where I instantiate @question instance variable. When I try to run this I get 'undefined met...
I have a simple model called Party with a corresponding table called parties. There's also a controller with all the usual CRUD actions and so on. This model is used in a website and only one admin user is allowed to edit the parties - everyone else is allowed to call GET actions (index, show). Nothing special so far. Now I need to do t...
Hi folks, I know this is probably on the Internet somewhere but I can't find the answer here on Stackoverflow so I thought I may boost up the knowledge base here a little. I'm a newbie to Ruby and Rails but my company is getting pretty invested in it so I'm trying to get to know it in a little more detail. It's been difficult for me t...
I've read only good things about Merb, but the documentation on the website is basically the api reference, and right now there is no books already published. Any resources about Merb? I guess that I'll start to read the code, but it'd be nice to have another sources of information ...
What replacements are available for pinging an ip address in Ruby? The stdlib "ping" library seems to be pretty limited in functionality. I'm not interested in rolling my own code here. Are there good gems available? Should I just suck it up and live with it? (I'm coding in Ruby 1.8.6 on Linux) ...
I'm trying to write a simple ruby function that can prompt the user for a value and if the user presses ENTER by itself, then a default value is used. In the following example, the first call to the Prompt function can be handled by pressing ENTER by itself and the default value will be used. However, the second time I call Prompt and pr...
Backstory I'm on Rails 2.1 and need to freeze the Capistrano gem to my vendor folder (as my host has broken their cap gem dependencies and I want to make myself as independent as possible). On my local windows machine I've put the following my environment.rb config.gem "capistrano", :version => "2.5.2" config.gem "net-ssh", :lib => "n...
Hello, rails friends. I'm struggling here with a problem: I have a controller questions which has action new. Whenever I need to create new question, I'm typing /questions/new What changes to routes.rb should I make to change the URI to /questions/ask Thank you. Valve. ...
By default, when you sudo gem install thegemname it will install executables into /usr/bin/ Is there a way to change this? For example, to install them into /usr/local/rubygems/bin (or any other path)? The path doesn't seem to be hard-coded into the gemspec file, so I don't see why this shouldn't be possible (although I have very littl...
I've been attempting to hook a Rails application up to ActiveDirectory. I'll be synchronizing data about users between AD and a database, currently MySQL (but may turn into SQL Server or PostgreSQL). I've checked out activedirectory-ruby, and it looks really buggy (for a 1.0 release!?). It wraps Net::LDAP, so I tried using that instead,...
I want to run a standalone ruby script in which I need my RoR environment to be used. Specifically, I need my models extending ActionMailer and ActiveRecord. I also need to read the database configuration from my database.yml. How do I go about it? ...
How do you check that monkey patching has been done to a specific class in Ruby? If that is possible, is it also possible to get the previous implementation(s) of the attribute that's been patched? ...
I have this quiz rails app linked to an IRC bot who asks questions (yes, on IRC), where I have this Question model which contains, well, questions, answers, hints, and a few more things. I started with Quiz model (like, say, the special Halloween or Christmas quiz) with a quiz_id in the questions table, then, I told myself, that it wou...
I realize this perhaps a naive question but still I cant figure out how to call one method from another in a Ruby class. i.e. In Ruby is it possible to do the following: class A def met1 end def met2 met1 #call to previously defined method1 end end Thanks, RM ...
Consider the following: irb(main):001:0> class A irb(main):002:1> def initialize irb(main):003:2> @string = "my string" irb(main):004:2> end irb(main):005:1> def to_s irb(main):006:2> puts @string irb(main):007:2> end irb(main):008:1> end => nil irb(main):009:0> a = A.new => #<A:0x2ea606c @string="my string"> irb(main):010:0> puts a my ...
I'd like to write a functional test of a RESTful web service I'm working on in a Ruby on Rails app. The test is of a POST request where the body of the request is a plain XML doc and not a form. Any pointers on how to do this? The problem I'm encountering is how to specify the body XML in the call to the post method. ...
This question is best summed up with a code example: module TestOne module Foo def foo 42 end end module Bar include Foo end class Quux include Bar end end TestOne::Bar.ancestors # => [TestOne::Bar, TestOne::Foo] TestOne::Quux.ancestors # => [TestOne::Quux, TestOne::Bar, TestOne::Foo, Object, Kernel]...
Say I have two tables, a master list of students containing personal info, and a list of student enrollments in classes. The two tables share a common column, which is a string uniquely identifying the student, but it is not the primary key. Say I want to display all the enrollments on a page, along with some of the personal data from ...