Let's say we have a hash:
flash = {}
flash[:error] = "This is an error."
flash[:info] = "This is an information."
I would like to convert it to a string:
"<div class='error'>This is an error.</div><div class='info'>This is an information".
in nice one liner ;)
I found something like that:
flash.to_a.collect{|item| "<div class='#{...
Rails' ActiveRecord::Base class defines an == method that returns true if the objects are identical or they have the same ID.
I've overridden == in a couple of my Rails models to allow for more meaningful equality conditions. These work when I compare objects directly (e.g., through script/console), but if I do something like my_array_o...
There is Ruby on Rails (1.8, 2.3.2) project. First version of project was made by some organisation. I will implement next versions of this project without any help from this organisation. I will be able to talk with developers from previous development team during meeting (1-3 hours).
Project statistics: ~10k LOC, 1.0/0.6 code to test ...
I have a map generated by others with data structure like this:
x = {"city": "London", "country": "England", "region": "Europe"}
I want to manipulate the data in Ruby. So in order to be able to let Ruby understand it's a map, I need to replace all ":" to "=>". Is there a quick way to accomplish this in one line?
...
I'm using rcov on a set of tests autogenerated from my rails routes to collect information on dead code (code which is never called in the application). This set up already generates enlightening results for controllers, models, helpers, and lib code. Unfortunately rcov does not track code coverage in erb templates, which makes sense a...
Hi All,
Please help me to solve this.
This is my string
str = "aaa\n\n\nbbb\n\nccc\ddd\n" means four blank lines, all together eight lines
I want to return this in one line
Output should be like this (aaabbbcccddd) in single line
I used various trim functions to get the output but still i am failing to do it. if Anyone know the pos...
I am trying to create a script to help me move large files accross an internal Windows network, and was hoping that Ruby, in conjunction with BitTorrent would be ideal. However, my code doesnt seem to actually download anything.
I know the RubyTorrent project has been abandoned for a long time, so I was hoping one of my fellow Stackove...
Possible Duplicates:
How to develop iPhone applications on a windows PC
How can I develop for iPhone using a Windows development machine?
I'm looking to build an iPhone app for my wife's phone, but am not interested in buying a Mac as a development platform for a one-off piece of work. The app:
should run standalone on the ...
Hi, I have a task of writing some test cases on Ruby.
The task is as in example:
Visit the some website.
(Assert that certain page was displayed)
Enter a text into a textbox
Press the submit button
(Assert that user was redirected to a right page)
(Assert that user was presented with the right information)
So, the question is: how to...
I have a program that looks like:
$offset = Point.new(100, 200);
def draw(point)
pointNew = $offset + point;
drawAbsolute(point)
end
draw(Point.new(3, 4));
the use of $offset seems a bit weird. In C, if we define something outside of any function, it is a global variable automatically. I wonder why in Ruby, it has to be $offse...
expect is a module used for spawning child applications and controlling them. I'm interested in python/ruby.
...
I'd like to write a Rake task that will load some development data for my app so I can see what the design looks like in the browser with some data populated in there. I've tried hacking together something using ActiveRecord and the Faker gem, but I'm having a hard time keeping it simple and practical. It quickly turns unwieldy.
Problem...
Some Ruby librararies I'm using use require statements like this:
require File.dirname(__FILE__) + '/specification_helper.rb'
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "lib"))
require File.join(File.dirname(__FILE__), 'lib/tools', 'version')
require File.expand_path(File.join(File.dirname(__FILE__), 'datautils', 'c...
At work, we recently started a project using CouchDB (a document-oriented database). I've been having a hard time un-learning all of my relational db knowledge.
I was wondering how some of you overcame this obstacle? How did you stop thinking relationally and start think documentally (I apologise for making up that word).
Any suggest...
When using Validates_uniqueness_of with the :scope option, is it valid to pass an array of columns like this:
validates_uniqueness_of :x, :scope => [:y, :z]
As I want :x to be unique in the context of both :y and :z
If not then how could you achieve this? 2 validations one for each scope?
Thanks
...
Is there any ruby gem/ rails plugin available for parsing the resume and importing that information into an object/form ?
...
I'm trying to use fixtures to add more complex test data in order to test specific scenarios with the front-end, which is in Flex. I'm not sure this is the right way to go about it with rails. My rails app is a card game and the 'more complex test data' I'm trying to test are various combinations of cards.
For example, I want to set up ...
I set up hoptoad on my prod server and ran rake hoptoad:test. I get the notifier in my hoptoad interface so it seems to work great. But then I forgot to migrate my database after my last deploy so I got a "ActionView::TemplateError" in my production log. This caused a 500 so I feel like HopToad should have notified me about this. Hav...
I develop my rails applications at my local machine.
How can I easily show friends of mine the current state of the project?
I have heard of tunnlr, but I am a poor student that looks for a free solution:-)
Best regards
...
I 've researched and noticed that ActiveResource lack this functionality. So, what is the current state of the art when doing a file upload?
One problem with Guillermo's approach is that the request has to be nested, like this:
body = { :file => {:uploaded_data => File.open("#{RAILS_ROOT}/public/tmp/" + original_filename), :owner_id =>...