Our Rails application has two environments that we deploy to servers a Staging environment and the default Production environment.
The staging.rb file is a copy of the production.rb form the config/environments folder. The difference between the two is whiny nils is set to true:
config.whiny_nils = true
Since the rails application ...
If I know the current_user's answers because the User model has an answers collection:
current_user.answers
How do I test whether that answers collection contains the current answer (referenced by the @answer class variable) at each step of a loop?
I was tempted to use the include? method:
current_user.answers.include?(@answer)
bu...
I'm trying to upload an image to PingFM. Their documentation says:
media – base64 encoded media data.
I can access this image via the URL. I tried (practically guessed) this:
ActiveSupport::Base64.encode64(open("http://image.com/img.jpg"))
But I get this error:
TypeError: can't convert Tempfile into String
from /usr/lib/ruby/...
Perhaps I am just not using the correct terminology for Ruby (and if I am please correct me), but Google just isn't helping me on this one.
What I have is a class (call it OrderController) that extends another class (call it BaseStoreController). In the BaseStoreController I have defined a before_filter that is used throughout my site, ...
Hi! How to use list/array as property in DataMapper on Jruby on Google AppEngine?
...
Hey there
Annoying problem. I am trying to replace all semicolon characters in my Model's description field with newline characters (\n). The database is sqlite. The field is of type text.
If I do it manually at the rails console (manually typing the description for a single record using \n for line breaks), the rails console automati...
I tried to require Gosu's .so file, but it said something about "expecting assembly",
I assumed that IronRuby will support library files which aren't written in dot net, may anybody help me please?
...
Hi everyone,
I'm a C++/C#/PHP/Javascript programmer who's been interested in learning Ruby for a while now. I just graduated and considering this means I no longer have homework to do, I figured now might be a good time.
Just one thing, I don't know where to start. Can someone point me in the direction of some good Ruby tutorials, what...
I'm running with MacRuby 0.5 and I have a method:
attr_accessor :bookmarkSheet, :mainWindow
def createBookmark(sender)
NSApp.beginSheet(bookmarkSheet,
modalForWindow:mainWindow,
modalDelegate:self,
didEndSelector:nil,
contextInfo:nil)
end
which is supposed to open up a sheet panel on the main window. However, wh...
Pardon the total newbiew question but why is @game_score always nil?
#bowling.rb
class Bowling
@game_score = 0
def hit(pins)
@game_score = @game_score + pins
end
def score
@game_score
end
end
...
I'm using Ruby's CSV library to parse some CSV. I have a seemingly well-formed CSV file that I created by exporting an Excel file as CSV.
However CSV.open(filename, 'r') causes a CSV::IllegalFormatError.
There are no rogue commas or quotation marks in the file, nor anything else that I can see that might cause problems.
I suspect the...
I think I'm missing something here. I have a directory like this:
myapp
|-lib
|-package1
|-dostuff.rb
|-package2
|-dostuff.rb
From an irb console I'm trying to test the library before I add it to my real project (a Rails app). However, typing this:
require 'lib/package1/dostuff'
returns an error saying it can't find ...
should teach both analysing the data and presentation, with code examples, preferably Java or Ruby.
...
Hi all,
I'm working on my first ORM project and am using Mechanize. Here's the situation:
I'm downloading a zip file from my website into a Mechanize::File object. Inside the zip is a file buried three folders deep (folder_1/folder_2/file.txt). I'd like to pull file.txt out of the zip file and return that instead of the zip file itse...
$("br",top.document).parent().contents().each(function() {
textx = this.textContent.replace(/\s+/g, '')
if ( this.nodeType == 3 && textx.length ) {
$(this).wrap('<div id="uniqja__' + numero + '"></div>')
}
})
...
Which of the following pieces of code is more expensive?
x = my_array.inject {|sum,i| int+=i }
or
x = eval(my_array.join('+'))
...
It only happens in production, when we update some of the records through browser, the change was not saved. it does not seem to be a cache problem as we verified that the data in mysql was still the old data. However, the controller did get hit and flash message returned as if the change was made successfully.
However, we can make the...
I'm writing a library to humanize bytes in Ruby (e.g. to turn the byte count 1025 into the string 1.1K), and I'm stuck on one element of the design.
The plan is to extend Numeric with ahumanize method that returns a human-friendly string when called on a number. After looking at the source of Number::Bytes::Human (a Perl module that I ...
If I use permalink_fu on a text field I get this for the resulting permalink:
http://localhost:3000/243webb4ee4ff2227230b4232438591810c35d3f
instead of
http://localhost:3000/where-is-my-lost-cat
I assume this is because the text field becomes a blob in the database and permalink_fu only knows how to operate on string fields.
How ...
I am trying to set up a web service to Celltrust's SMS Gateway. I have their SDK and I'm trying to use soap4r to create the custom headers that it needs. I'm not sure exactly what I need to do to get it in their format, since they don't provide me with an actual XML document showing what they need; all they say is that in the header yo...