[Rails] Re: strings issue
thelo.g thelo wrote in post #1018739:
> I tried but it doesn't work, is it possible that the mistake has a ling
> with \n at the end of r? because when I do:
> puts '"' + r + '"'
>
> I get
> "Archives-2011-08-26-09-56-00-UTC.xml
> "
It's not only possible, that is exactly what is at the end of r. When
you are having such a problem, it is easier to see what the string
actually contains by doing one of the following:
1) puts "-->#{some_var}<---"
2) p r
which is the same as:
puts r.inspect
Here is an example:
str = "hello
world"
p str
--output:--
"hello\nworld"
And of course the newline makes a difference in the file name. You can
test that yourself:
some_file = "html.htm"
File.open(some_file) do |f|
puts f.read
end
Once you get that to work with a file on your file system, try adding a
\n to the end.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home