I've set up Rack::Reload according to this thread
# config.ru
require 'rubygems'
require 'sinatra'
set :environment, :development
require 'app'
run Sinatra::Application
# app.rb
class Sinatra::Reloader < Rack::Reloader
def safe_load(file, mtime, stderr = $stderr)
if file == Sinatra::Application.app_file
::Sinatra::Appli...
I want to do something like
assert_match /blah blah blah #{@user}/, @some_text
but I'm not having any luck with it working.
What am I doing wrong here?
...
hi all
I have a rails app that creates quotations with information and images on that can be very different in size and the data they display.
Each quote contains many setions of varying sizes.
I need to find a way to auomatically put page breaks into the quote when printing so that none of th sections are cut into printing on 2 pages...
PCRE: /\A[A-Z0-9_\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[a-z]{2,4}|museum|travel)\z/i
POSIX: /^[A-Z0-9_\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[A-Z]{2,4}|museum|travel)$/i
This regex is correct in every way for my needs except that it allows emails such as [email protected]. It says these are a match. If I'm not mistaken, doesn't the {2,4} after [A-Z] mean th...
I have a bunch of files in a directory. I want to zip some of them together into a zip archive.
I can see there are various solutions for doing so. I could use a gem such as rubyzip or run exec and just use a command line tool.
This is going to impact an important part of the system I'm working on so I'd love to have some feedback and...
Hi all,
How we can define JS function on inside ? I tried to load file javascript on the end tag , but I still can't call the function from javascript file.
Here the FBML tag
<fb:serverfbml>
<script type="text/fbml">
<fb:fbml>
<a href="#" id="this" onclick="do_colors(this); return false">Hello World!</a>
<script src=...
I am building a project management app and I am not sure which is the best/correct authentication model to implement given I am new to Rails (and programming in general). Here is what I am trying to do.
I want to be able to add a "client" to the application and then multiple projects to a client. I would like to be able to add users (t...
It´s really a hard job figuring out how to get MySQL and mysql gem up and running on Snow Leopard 10.6.2. I followed the instructions of various posts but was not successful yet:
I build MySQL Version 5.1.39 from source and it installed successfully. When trying to login using (mysql -u root -p) mysql returned the following error:
ERR...
Hi, I'm trying to implement a CLI type application in Ruby.
The CLI should accept commands using a grammar that I wish to define. I've found some leads on how to implement and parse a grammar (RParsec) but I don't see how I can hook that up to some code to acutally execute the command.
Commands would be something like (very rough id...
Does anyone know how to use Ruby to grab a list of the MAC addresses of all the devices on the local network? Preferably as quick a response as possible.
Thanks!
...
hi all
i have select box where on change i need to grab the value and via remote function get some field names from db and then generate those field further down the form depwning on whatoption from the select box is chosen.
The problem is is that the fields are in a f.form_for so are using the formbuilder f that has the select box in...
In the Bash shell, I would like to run a directory of ruby scripts from anywhere. Adding the directory to the $PATH doesn't do it.
I want to type 'ruby,' start typing the first letters of a script name, and then press tab to autocomplete the script name.
For instance, I'm in /~/username/foo/bar and want to run /~/ruby/test/script1.rb
...
I'm trying to set up custom Pingdom monitoring of my Rails application and would like to craft an XML response that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<pingdom_http_custom_check>
<status>OK</status>
<response_time>210.22</response_time>
</pingdom_http_custom_check>
Where the response_time value is the time tak...
I have written a Ruby (not Rails) app which generates web pages. The script is installed on a linux web server and is called up by apache using CGI in response to HTTP requests. Pretty standard stuff.
When I am running it on my own computer I look at the apache error log to see the ruby error messages.
However, on the host that I use ...
I am trying to identify a user ID number, to grab a Student row from an ActiveRecord table, but for some reason the 'post' block won't find my :id.
For the 'get', the url is localhost:9456/update/17. It's this 17 I need to pass to the 'post' block to update the database.
I am not sure how to do this. Parse the URL? It seems like I am m...
I've been using the built-in OSX 'say' command to signal the end of long running tests. It's easy and convenient.
I'd like to make it speak the last line of the results which says "6 tests, 18 assertions, 0 failures, 0 errors" but still keep the ongoing output. Any ideas how to do this?
I've tried:
ruby overlay_test.rb | tail -n 1 | ...
I have such angry associations: financings >- events >- subprograms >- programs. I want to get acces to last_financings from programs through all of them so code is:
class Fcp < Program
has_many :fcp_subprograms,
:foreign_key => 'parent_id'
has_many :subprogram_last_actual_financings,
:through => :fcp_subprogra...
I can do:
@items = @items.select {|i| i.color == 'blue'}
@items = @items.select {|i| i.color == 'blue' || i.color == 'red'}
What if I am given an unknown amount of colors and I want to select them all? i.e.
['red','blue','green','purple']
# or
['blue','red']
I've been working on a mess of code that creates several temporary arrays ...
I have decided to write a small interpreter as my next project, in Ruby. What knowledge/skills will I need to have to be successful?
I haven't decided on the language to interpret yet, but I am looking for something that is not a toy language, but would be relatively easy to write an interpreter for.
Thanks in advance.
...
I'm having problems actually sending via ActionMailer in development, on my localhost, with Rails 2.3.2 and Ruby 1.8.6. The development.log shows that it has "sent" the email with no errors, but the email is not received. I have tried multiple email addresses for sending and receiving and have tried multiple configs and plugins, but cann...