How does one do namespaced controllers in Merb, for instance to create an admin section to the site? In Rails one would use Admin::CategoriesController, is this similar in Merb or is this another recommended way of doing it?
...
Is it possible to retrieve the CPUID and MAC address of a client machine from a Ruby on Rails application?. Are there any plugins available for this?
...
In my models, there are lots of attributes and methods that perform some calculation based on the model instance's attributes. I've been having the methods return nil if the attributes that the calculations depend on are nil. As a consequence of this design decision, I'm doing a lot of nil checks before displaying these values in my vi...
I've been looking at some Ruby dependency injection libraries. In particularly, I checked out Needle and Copland. They've been around for quite awhile, yet not a lot of usages.
What are some of the pros and cons of using these two libraries? It sure seems like a lot of libraries / frameworks out there could make good use of these t...
First a bit of background.
I have been working on the MS platform for my entire development career. Up until 2 weeks ago, I had never booted any other OS than 98/XP/Vista. I started using VSS long long ago, and made the change to SVN about 2 years ago. With SVN I use TortiseSVN and use the standard branch/tag/trunk setup.
My projects ...
Hi, I've written a rails app that follows the regular directory structure (model code in models, controller code in controllers).
But I'm now working on a new feature and for that I have written some (what I would call) "service" code.
The new feature is to import some data into the system, at the moment it's two classes to do the impor...
I'm building a tool that automates a process then runs some tests on it's own results then goes to do some other stuff.
In trying to clean up my code I have created a separate file that just has the test cases class. Now before I can run these tests, I have to pass the class a couple of parameters/objects before they can be run. Now the...
Up till now all my programming experience has been desktop development (mostly C/C++ with OpenGL/DirectX) but I'm interested in trying my hand at some web dev.
The two directions I'm considering are Ruby on Rails and ASP.net.
Which is most widely used?
Which would be a more marketable skill to have?
Thanks!
...
In .Net, I found this great library, HtmlAgilityPack that allows you to easily parse non-well-formed HTML using XPath. I've used this for a couple years in my .Net sites, but I've had to settle for more painful libraries for my Python, Ruby and other projects. Is anyone aware of similar libraries for other languages?
...
Does Ruby have any tools along the lines of pylint for analyzing source code for errors and simple coding standards?
Would be nice if it could be integrated with cruisecontrolrb for continuous integration.
Or does everyone write such good tests that they don't need source code checkers!
Thanks
...
I'm writing a ruby program that executes some external command-line utilities. How could I mock the filesystem from my rspec tests so that I could easily setup some file hierarchy and verify it after testing. It would also be best to be implemented in ram so that tests would run quickly.
I realize that I may not find a portable solutio...
Does anyone know of any method in Rails by which an associated object may be frozen. The problem I am having is that I have an order model with many line items which in turn belong to a product or service. When the order is paid for, I need to freeze the details of the ordered items so that when the price is changed, the order's totals a...
I thought this code would work, but the regular expression doesn't ever match the \r\n. I have viewed the data I am reading in a hex editor and verified there really is a hex D and hex A pattern in the file.
I have also tried the regular expressions /\xD\xA/m and /\x0D\x0A/m but they also didn't match.
This is my code right now:
li...
Hi all,
I have two tables:
Client(id,name,...)
Purchase(id,item,date,client_id,...)
They have their respective Model, with their validations. What I need is to create a new client with a new purchase, all into the create method of Client controller. Something like this:
def create
@client = Client.new(params[:client])
respond_t...
I found one source which successfully overrode Time.strftime like this:
class Time
alias :old_strftime :strftime
def strftime
#do something
old_strftime
end
end
The trouble is, strftime is an instance method. I need to override Time.now - a class method - in such away that any caller gets my new method, while the new me...
In a previous question about overriding Time.now, I was working toward a solution of faking clock synchronization across all machines connecting to a given database. Overriding Time.now seemed the best way for the approach I was taking, however:
It appears as though I could get the result I was after via a much simpler line. If I can ...
I'm looking to develop a website that will be fairly database intensive and that will be playing quite a few videos. My question is this: I don't have any experience as a programmer and I'm trying to figure out whether or not I should learn Ruby on Rails or Flex...or both. I have several people that are working on this project with me th...
When using regular expressions in Ruby, what is the difference between $1 and \1?
...
How do you check whether a variable is defined in Ruby? Is there an "isset"-type method available?
...
I want some slightly 'dynamic' XML source files. I want some of the element values to be dynamic, or 'expandable'.
I'm providing a value for this variable, from some other source.
@Name = 'freezingkiwis'
What I want to provide is something like this in an XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Contact>
<Name>#{@Name}...