From what I have understood, the equal method checks if the object is the same.
person = Person.create!(:name => "David")
Person.find_by_name("David").should equal(person)
This should be true.
But aren't there two different objects here?
How could two objects be the same? I don't understand that.
...
I'm trying to setup a very basic id="thisFileName" in my staticMatic project.
So far I've managed to apply the following to an /index.html (the HAML output):
- @slug = current_page.gsub(/\.html/, '')
Which returns "/index". However - I'd like to remove the / at the start so that it reads /index...
Any tips or directions for where ...
Im not very updated in the event-driven/concurrency area in node.js.
I wonder, is it possible that node.js would replace ruby/rails completely in the future?
Or is it more like an extension to ruby/rails for the real time features?
...
Can someone please tell me how to convert this line of Javascript to Ruby using Hpricot & RegEx?
// Replace all doubled-up <BR> tags with <P> tags, and remove fonts.
var pattern = new RegExp ("<br/?>[ \r\n\s]*<br/?>", "g");
document.body.innerHTML = document.body.innerHTML.replace(pattern, "</p><p>").replace(/<\/?font[^>]*>/g, ...
I've just recently started writing my own gems. One of them requires the gnuplot gem, like so:
module Rocker
require "gnuplot"
# ... module code here ...
end
It works great, right up until I add my gem to config/environment.rb on one of my Rails projects. Then, not a single page will load. I get errors like this:
TypeError in ...
Can someone please explain how to add a custom attribute to an HTML tag using Ruby with Hpricot gem?
I have a tag that looks like this:
<div class="test" id="tag1" style="">
and I want to add a custom integer attribute called 'Readable=0' so it looks like this:
<div class="test" id="tag1" style="" readable=0>
Is this possible?
...
I am writing a helper that needs to call another helper, which generates html. How do I do that?
...
I am developing a rails application that will eventually contain products, users, and orders. For now I am just trying to get their 'brochure site' up. Rather than build it twice I thought to simply start with the rails application making it easily to rapidly move on as they need. That said...I am looking for advice on the best way to bu...
This is when using a view file to generate an excel file. like:
in controller:
headers['Content-Type'] = "application/vnd.ms-excel"
headers['Content-Disposition'] = 'attachment; filename="report.xls"'
then in view:
<table><tr><td>foo</td><td>bar</td></tr><table>
Is it possible to add formatting such as color to cells? like:
<td st...
For now ,i want to run exe file from my disk, after finished to install that exe file, will show a popup message which tell user that already finished install exe file, but i do not konw how to close the popup message.
Does anyone know how to do that ??
thank you very much
...
I'm using Rails 2.3.5, paperclip 2.3.3 with rspec and factory_girl.
Can't figure out why the attr_accessors are undefined when I try to test upload or simply calling. e.g.
account.profile_photo.file?
undefined method `profile_photo_file_name' for #Account:0x105970af8
Where I have it running properly in Development.
account.rb
h...
Hello everyone,
I am currently running ruby-1.9.1 installed via RVM. I have been looking at using Merb, but when I try and run it I get this error:
sam@shiny-dev:~/Projects/mojo$ rake db:migrate
(in /home/sam/Projects/mojo)
Merb root at: /home/sam/Projects/mojo
/home/sam/.rvm/gems/ruby-1.9.1-p378@merb/gems/dm-validations-...
Hi,
AIX 5.3
DB 10.2.0.4
My requirement is to create a script that does export a big table from source to remote destination server and on remote destination database server to create another script that import that export table.
In export script I need to add to purge exported data and it schedule on weekly basis.
Thanks,
...
If I need to define a method called 'yields' which will call yiled 3 times:
def yields
3.times do
yield
end
end
And then I will use it in an other method:
def call_me_3_times
yields
end
In the console or irb:
>> call_me_3_times { puts 'me'} # => Cause error
=> LocalJumpError: no block given (yield)
from (ir...
Hello, I am currently trying t implement a model to simplify graphical chart creation. However, one of the attributes must be an array of attributes. For example:
"Chart_Series" has a "name" which would be a string and a data field which would be separated by dates which is an array of arrays [[Date1, Value1],[Date2,Value2],[Date3,Value...
How can I parse a string of fullwidth unicode integer characters to an integer in ruby?
Attempting the obvious results in;
irb(main):011:0> a = "\uff11"
=> "1"
irb(main):012:0> Integer(a)
ArgumentError: invalid value for Integer: "\xEF\xBC\x91"
from (irb):12:in `Integer'
from (irb):12
from /export/home/henry/apps/bin/...
Hello, in an attempt to create a model with an array as an atribute, i ended up creating an array of hashes like so:
data1 = {}
data1[:name] = "Virtual Memory"
data1[:data] = @jobs.total_virtual_memory
data2 = {}
data2[:name] = "Memory"
data2[:data] = @jobs.total_memory
@data = []
@data << data1
@data...
I have to process a block of text, which might have some spurious newlines in the middle of some of the fields. I want to strip these newlines out (replacing them with spaces), without stripping out the 'valid' newlines, which are always preceded by a \t.
So, i want to replace all newlines that are not preceded by a tab with a space. ...
In my rails app, i convert a idn url to punycode and back to idn.
But if i have a url like this http://日本語.jp (without www.)
domain = "http://日本語.jp"
punycode = Idna.toAscii(domain) => http://xn--blagzdfd.com
but trying to convert it backto IDN fails
idn = Idna.toUnicode(punycode) => xn--blagzdfd.com instead of http://日本語.j...
This is really odd: I installed ruby 1.9.1 using a "191" suffix so that it will coexist with other versions. e.g. the executables look like ruby191, gem191 and the library directory where all of the vendor/site code lives is /usr/local/lib/ruby191. The version of RubyGems (1.3.1) that is included with ruby 1.9.1 works fine. The insta...