I don't know if this is bad form or not, but I needed to set a file path that's accessible to all objects within actions in my controller. One action in the controller creates a file and stores it in a path. Another action serves the file using send_file. The only place I have been storing variables is along with an object in the model. ...
Hi everyone
If you don't install gems with sudo on a mac, by default they will be placed in a directory like
.gem/ruby/1.8/gems/
If you DO install by with sudo, my understanding is they are normally placed in the system directories, like so:
/usr/local/lib/ruby/gems/1.8/gems/
Is there a good reason you should install gems with ...
Hi all.
I've found this tutorial (http://www.coffeepowered.net/2009/02/15/graceful-degredation-using-gravatar-as-a-fallback-avatar-with-paperclip/) about implementing gravatar as default image to the paperclip-enabled model, but on implementing i see message "undefined method `match' for [:format, :png]:Array". Whats wrong in this articl...
Hi,
We need to develop a functionality for one of our client's website. However, we actually have that code ready in Ruby. Is there any way to directly convert that ruby code to PHP?
...
I'm looking for ideas/information about managing temporal data with Active Record (Rails). One example would be the emplyoment history (working 100% in january, but only 80% from february up to now). This proably would be easy to tackle with a traditional 'has-many :eployment_parts'. But there's another case where the user can plan somet...
I'm writing a crawler for Ruby, and I want to honour the headers that the server sends out in order to make the crawl more efficient. Is there a straightforward way in Ruby of determining whether a page needs to be re-downloaded by the client? I know I need to consider at least these headers:
Last Modified
Etags
Cache Control
Expires
...
I have to develop a online product catalog which will eventually developed into a simple online ordering system, I have never developed a web application before. Please recommend an application framework which might be a good choice for this kind of apps.
Is Ruby on Rails a good choice?
Thanks.
...
I know that any language is capable of parsing XML; I'm really just looking for advantages or drawbacks that you may have come across in your own experiences. Perl would be my standard go to here, but I'm open to suggestions.
Thanks!
UPDATE: I ended up going with XML::Simple which did a nice job, but I have one piece of advice if you ...
I have the following array:
votes_array = [["2", "1"], ["2", "4"], ["4", "3"], ["3", "4"], ["1", "N"], ["3", "1"], ["1", "2"], ["4", "1"], ["0", "1"], ["0", "2"], ["1", "3"], ["1", "4"]]
And I want to create a new array (or hash) that stores the votes_array items by their first option so that the new array looks like this:
candidate_...
Is there a nice quick way to get every other entry in an array in Ruby ?
Either the odd or even entries values with 0 included in the odd.
I'd like to be able to use it like this
array1 += array2.odd_values
or
puts array2.odd_values.join("-")
for example
Update
This give exactly what I'm after but I'm sure there is a shorter ve...
What are the pros and cons between PaperClip and Attachment_fu ?
Are there any other plugins that would you recommend ?
Is possible to support multiple file uploads and progress feedback on upload using these plugins and Passenger + Apache
...
I've been looking around for a solution to this question for the last couple of days. It's a simple annoyance, but I hate not knowing how to do things...
Environment: Ruby, Rails, rhtml
The Problem: When I iterate a collection in rhtml I would like to reduce the number of <% %> and <%= %> tags I use. The following seems bloated:
Exa...
Hi, i want to do the following:
I want to declare the instance variables of a class iterating over a dictionary.
Let's assume that i have this hash
hash = {"key1" => "value1","key2" => "value2","key3" => "value3"}
and i want to have each key as instance variable of a class. I want to know if i could declare the variables iterating o...
I am learning Ruby and found this code sample in some documentation:
require 'find'
total_size = 0
Find.find(ENV["HOME"]) do |path|
if FileTest.directory?(path)
if File.basename(path)[0] == ?.
Find.prune # Don't look any further into this directory.
else
next
end
else
total_siz...
First time caller, long time listener...
I'm working on a utility that will scan USB ports and mount any Mass Storage devices it finds. I can poll for changes ( with a patched version of Ruby-USB ) but would much rather get a notification, or subscribe to some event.
Is there a way for Ruby to be tickled when a USB stick is inserted?
...
Experimenting with Ruby's Benchmark module...
>> Benchmark.bm(7) { |b| b.report('Report:') { s = '' ; 10000.times { s += 'a' } } }
user system total real
Report: 0.150000 0.010000 0.160000 ( 0.156361)
What are the meanings of "user", "system", and "real"?
...
Is there a standard method to create a new array from a two dimensional array so that array[x][y] would be accessed as [y][x] on the new array?
For example, from:
[ [00,01,02,03,04,05],
[10,11,12,13,14,15],
[20,21,22,23,24,25] ]
Would become:
[ [00,10,20],
[01,11,21],
[02,12,22],
[03,13,23],
[04,14,24],
[05,15,25] ]
...
Hi,
I am trying to create a simple Automator droplet that will take the style.less file dropped into it and run the following LESS command on it:
$ LESSC {DROPPED_FILE} --watch
which will monitor the file I have dropped in for any changes and will then automatically update the outputted style.css
FYI: I am using LESS to have dynamical...
I'm using BlueCloth to create html from markdown from the content my users enter into a textarea like this:
def create
@post = Post.new(params[:post]) do |post|
body = BlueCloth.new(post.body)
post.body = body.to_html
end
...
end
This works great! I get the html stored in the database fine, But how do I show markdown in...
I find the .each do hard to get to stick, so I was hoping for regular use of C for loop syntax which seems to not work, so I tried a while but still get errors.
I have tried this.
i = 0
while i < SampleCount
samples[i] = amplitude
amplitude *= -1
i++
end
I get complaints about the end statement here.
...