Hi,
I am using REXML to edit an xml file but have ran into difficulties with formatting.
My original code looked like this:
file = File.new( destination)
doc = REXML::Document.new file
doc.elements.each("configuration/continuity2") do |element|
element.attributes["islive"] = "true"
element.at...
I am wondering what other people have found to be the best graphing libraries/plug-ins/gems etc for a rails app.
When I say best, I guess I mean ease of implementation and the ability to customize the graphs.
I have previously used openflashchart2 and loved the overall look/effects it has, although customizing everything as required ...
Something I'm not getting...
I have this in my model:
class Model < ActiveRecord::Base
has_many :model_options # a link table for many to many
has_many :options,
:through => :model_options,
:dependent => :destroy,
:foreign_key => 'model_id'
end
And I try to do this:
model = Model.fin...
Guys i have tried to refresh my page with a button..
<input type="reset" value="Refresh" />
but it not refreshing, not to refresh the textboxes jst to refresh the entire page.
...
I'm having an issue coming up with a good way to do the following. I have a very generic Org model and User model. Org has_many :users, and User belongs_to :org.
I am trying to find a way of showing a list of users that is not restricted by Org, but also show a list of User's that is restricted by Org. I know I could nest the routes, an...
Hey everyone,
I'm getting up to speed on rails and ran into an odd problem. I'm rendering some images from the database (Image models attached to another model, Plants). I'm having some trouble when attempting to do it via a partial. I've got show.html.erb
<fieldset class="fieldset">
<legend>Images</legend>
<%= unle...
I'm seeing this error when I run: rake/gem from my Git Bash. Anyone know what it means?
sh.exe": /c/Ruby/bin/gem: D:/Users/Luis/projects/oss/oci/installer2-trunk/ruby/bin/ruby.exe^M: bad interpreter: no medium
Running under Windows/Cygwin - specifically in the Git Bash shell.
...
I am attempting to make a simple connection to a remote database. I can not seem to get it to work.
remote_db = DBI.connect('DBI:ODBC:remote-host','user','password')
remote_db.table { |table| pp table }
Any help would be greatly appreciated.
...
I have the following code:
def show
@game = $site.new_game_of_type(params[:id])
@game.start
end
def update_game_time
render :partial => 'countdown', :layout => false
end
and the countdown partial:
<div id=countdown> <%= @game.running_time %></div>
In show.html.erb I have:
Time: <div id="countdown"> </div>
<%...
I'm currently using Capistrano along with the multistage extension to manage deployments. Even after setting :domain in config/deploy/stage.rb, when calling 'cap stage deploy', its prompting me for a domain name for the project. What setting am missing?
Here is my deploy.rb
set :stages, %w(vm rtpstage ciscostage ciscodemo hp)
require ...
Question: Instead of getting transformed output from my ERB template, is there a parameter, setting or hack I can use that will output the raw ruby code that gets generated right before the transformation runs?
Rationale: I am having trouble figuring out the problem with an ERB template syntax error, and I would like to see the plain ru...
When I try to create a soap object, I get a fault when I first initialize the class. I can't set driver.options["protocol.http.ssl_config.verify_mode"] = OpenSSL::SSL::VERIFY_NONE because its already faulted. Any ideas?
require 'soap/wsdlDriver'
=> []
wsdl = "https://somesiteinhttps.com"
driver = SOAP::WSDLDriverFact...
I want to use cache-money but I don't want to start automatically caching everything (I'm working with a large production app, terabytes of data etc). How do I use it for only the models that I specify? Right now I've got:
# initializers/cache_money.rb
require 'cache_money'
config = (cfg = YAML.load(IO.read(File.join(RAILS_ROOT, "con...
Can anyone tell me what's wrong with this code?
class Dataset < ActiveRecord::Base
has_many :dataitems
def self.get_hash(dataset_id)
@dataitems = Dataset.find_by_id(24).dataitems
@dataitems.each do |di|
dataset_hash[di.axis0value] = di.axis1value #assign value for each category value
end
return dataset_hash
end
When...
I have seen two commonly used techniques for adding the directory of the file currently being executed to the $LOAD_PATH (or $:). I see the advantages of doing this in case you're not working with a gem. One seems more verbose than the other, obviously, but is there a reason to go with one over the other?
The first, verbose method (coul...
Does a easy to use Ruby to Python bridge exist? Or am I better off using system()?
...
It's been a while since I last did Ruby programming -- looking at somebody else's code, I see the @ sigil in a function (not a method -- external to any class definition), which I understood to be scoped to instance members.
Is the module the implied self in functions?
...
I have an underlying ruby game-engine code and I want to use the web interface to let know the user what's going on and interact with the underlying dynamically created data.
To this effect I want to create a new game variable when a link is press and I want that variable to survive till the user goes out of the page just as a flash o...
I am testing AlumniOnRails (http://rubyforge.org/frs/?group_id=2959&release_id=17170) which is based on Rails 1.2.6 (I know it's outdated) and managed to get it up, installed the required gems, created and migrated the data and most of the basic alumni functionalities are up but one, the part that is broken seems to be missing a libr...
I am pretty formatting a floating point number but want it to appear as an integer if there is no relevant floating point number.
I.e.
1.20 -> 1.2x
1.78 -> 1.78x
0.80 -> 0.8x
2.00 -> 2x
I can achieve this with a bit of regex but wondering if there is a sprintf-only way of doing this?
I am doing it rather lazily in ruby like so:
("...