I have a sinatra service foo.rb
To run it I on a different port I would type "ruby foo.rb -p 5000".
While the program is running I would like to be able to get the port (in this case 5000) and other information. Is there a way to get info like this while the app is running?
Thanks
...
I'm not quite sure how to go about diagnosing this issue, after switching my app to Ruby 1.9.1 I'm getting this error:
TypeError
wrong argument type Mysql (expected Struct)
And it seems the app fails to boot, so I'm not really sure of how to even begin solving this issue. I've made sure all my gems are up to date and they are.
I'm us...
I am new to the language and I need to know what are the top things that are absolutely necessary to know in order to make a fully functional website or web app using the Ruby programming language?
Mainly Ruby on Rails with Rake and other tools that mainly use Rake.
Update: I know many other languages like C++, Java, PHP, Perl, etc, et...
I want to be able to display an HTTP 500 error with an XML builder template if the request Accept type is asking for XML. By default it displays 500.html, even if the request type is not asking for an HTML response.
...
For my RSpec tests I would to automatically associate data files with each test. To clarify, if my tests each require an xml file as input data and then some xpath statements to validate the responses they get back I would like to externalize the xml and xpath as files and have the testing framework easily associate them with the particu...
The title is a bit difficult to put together for this question.
Say I have two models, Foo and Bar. Foo has many Bar's. Bar belongs to one Foo. How do I use Foo.find to find all of the Foos that currently have zero Bars? In SQL this would translate into something like:
SELECT * from foo where id NOT IN (select foo_id from bar);
...
I'm working with some old code and using ActiveResource for a very basic Twitter integration. I'd like to touch the app code as little as possible and just bring OAuth in while still using ActiveResource.
Unfortunately I'm finding no easy way to do this. I did run into the oauth-active-resource gem, but it's not exactly documented and i...
Is there a way to dynamically inject partial templates (and have it work the same way in both Ruby & Javascript)? Basically, I'm trying to render different types of objects in a list.
The best I can come up with is this:
<div class="items">
{{#items}}
<div class="item">
{{#is_message}}
{{> message}}
{{/is_message}}
{{#is_pictu...
I just read a little about resque here and how you use redis as a "advanced key-value store" for the jobs.
As you might know you can use resque on multiple machines to process the jobs:
Workers can be given multiple queues (a "queue list") and run on multiple machines. In fact they can be run anywhere with network access to the Redi...
I have a Sinatra::Base object that I would like to include in all of my web apps. In that base class I have the configure method which is called on start-up.
I would like that configure code to 'register' that service with a centralized database. The information that needs to be sent when registering is the information on how to contac...
Are there any best practices in writing unit tests when 90% of the time I'm building the Oauth connecting class, I need to actually be logging into the remote service?
I am building a rubygem that logs in to Twitter/Google/MySpace, etc., and the hardest part is making sure I have the settings right for that particular provider, and I wo...
I'm trying to access the RAILS_ROOT constant in a file residing in the /lib directory, but I'm not able to (uninitialized constant error). Is there something that I need to require to be able to do this? Sorry if this is a dumb question..
...
I'm setting up a Linux development environment. After installing Ruby and RubyGems, I quickly found out that I need to require 'rubygems' in order to use gems, whereas I do not need to do this in Windows Vista. Is there anything I can do to fix this? Should I even be worrying about it?
...
I have an application that calls an other application that populates a directory. Once it is finished I want to provide a link to the directory that contains the created files and people can examine or download them via the browser:
For example this works to provide a link to a single file: (Note this uses HAML) but the idea is the sam...
C:\Users\rahul\Documents\University of California, Santa Barbara\scheduler\sbsch
eduler\gold_api>ruby access_gold_test.rb
C:/Ruby/lib/ruby/gems/1.8/gems/test-unit-2.0.0/lib/test/unit/testresult.rb:28: u
ninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameErro
r)
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems...
I'm iterating over a very large set of strings, which iterates over a smaller set of strings. Due to the size, this method takes a while to do, so to speed it up, I'm trying to delete the strings from the smaller set that no longer needs to be used as it goes along. Below is my current code:
Ms::Fasta.foreach(@database) do |entry|
...
I'm displaying a list of events. I wanted displayed the page with the events for today by default. That was easy accomplished by:
page = number_of_records_before_RECORD / number_of_pages + 1
Now I want to display the first item of today's events as the first item in that page.
Maybe there is a way to generate page numbers around a re...
I must have done something, but am going crazy trying to find my mistake.
After my last upload now all my URLs are pointing to localhost:3000 instead of the site.
It was working before. :(
This is only with items that call the absolute path like style sheets and javascripts.
UPDATE -
OK, so now everything is working again. Rebooted...
Hi,
when I do the following
def somefunction
@texts = A.find_all_by_someid(someid)
respond_to do |format|
format.xml { render :xml => @texts }
end
end
it gets the string from the db correctly, except if the string has leading whitespaces, it seems they are trimmed.
Note: the whitespaces are there in the db...
I'm always writing tests to check my controller restricts people from certain actions depending on their status i.e. logged in, admin? etc
Regardless of whether its a get to :index or a puts to :create the code is always the same. I'm trying to refactor this so that i have one method such as
should_redirect_unauthenticated_to_login_ac...