ruby

using ruby/rails to catch out going file request

Hello all, I'm working with a rails app which plays mp3s. Is there a way to catch the request for the mp3 file with ruby, reformat the request(url), and pass the request along? I'm really just trying to protect the urls... ...

ruby script/server not reading RAILS_ENV option

Hello, I tried to run ruby script/server RAILS_ENV=production but somehow it always try to read "development" config.. nothings wrong with RAKE XXX RAILS_ENV=production (trying to read production config). Any idea how to troubleshoot? I have my other rails app in the same machine and it works fine. The problem above only happen fo...

Heroku Rails Internal Server Error

Hello. I got a 500 Internal Sever error when I try to deploy my rails app on heroku. It works fine on my local machine, so i'm not sure what's wrong here. Seems to be something with the "sessions" on the home controller. Here is my log: ==> production.log <== # Logfile created on Sun May 09 17:35:59 -0700 2010 Processing HomeContro...

help configuring openid for enki blog in ruby on rails

I am trying to set up a blog using Enki. There is a config file here: http://github.com/xaviershay/enki/blob/master/config/enki.yml Which I don't understand. I signed up for myopenID and replaced my username in the delegate, but I don't understand what goes under "open_id" - is it just my URL? I'm just not sure what's going on, or what ...

Ruby HTML scraper written in Hpricot having trouble with escaped HTML

I am trying to scrape this page: http://www.udel.edu/dining/menus/russell.html. I have written a scraper in Ruby using the Hpricot library. problem: HTML page is escaped and I need to display it unescaped example: "M&amp;M" should be "M&M" example: "Entr&eacute;e" should be "Vegetarian Entrée" I have tried using the CGI library...

options.fetch . I don't get it

Look at the discussion on this thread . I am not able to follow how having a block to a fetch is a better solution. ...

How to get today's day of previous month in ruby?

Is there a built-in function to get the day in last month, same as today? Examples: 2010/05/02 -> 2010/04/02 2010/05/15 -> 2010/04/15 2010/05/31 -> 2010/04/30 Thanks! ...

Override same Class method in Ruby with Multiple Modules, with need to call super. Do I use Method Alias, or some other clever trick?

Here's the situation: I have a User model, and two modules for authentication: Oauth and Openid. Both of them override ActiveRecord#save, and have a fair share of implementation logic. Given that I can tell when the user is trying to login via Oauth vs. Openid, but that both of them have overridden save, how do "finally" override save...

In Ruby, how to implement "20 - point" and "point - 20" using coerce() ?

In Ruby, the operation of point - 20 # treating it as point - (20,20) 20 - point # treating it as (20,20) - point are to be implemented. But the following code: class Point attr_accessor :x, :y def initialize(x,y) @x, @y = x, y end def -(q) if (q.is_a? Fixnum) return Point.new(@x - q, @y - q) end Poin...

Selenium IDE and telling it to record actions

I am trying to make a little application to allow to record actions within a Flash and Silverlight application. In such manner that you can compile your interactive application in test-mode and then be able to click on elements which then passed the action to Selenium IDE which then adds this command to the testcase. I am curious if thi...

Embedding Ruby, calling a function from C

Hi, I'm writing an app that calls ruby code from c. I am having a little difficulty and wondered if anyone could point me in the rite direction. I currently have in my C. #include ruby.h main() { ruby_init(); rb_require("myRubyFile"); rb_funcall(rb_module_new(), rb_intern("RubyFunction"), 0, NULL); } My ruby file is in the sam...

Is there a shortcut for jumping to the end or the begin from a scope?

Hi I know from vim the % to move to associated ( ), { }, [ ]. How can I do that in textmate? ...

Needed help with deleting rails cache

I have been given a project of editing a website which is coded in RoR. However, the changes which i make in the view file is not visible immediately after a hard refresh but after 15-20 mins, the changes reflect. I am guessing this has something to do with the RoR caching system. Can someone please help me out ? The changes i made are...

Ruby on Rails - Primary and Foreign key

Hey, I am creating a site in Ruby on Rails, I have two models a User model and a Transaction model. These models both belong to an account so they both have a field called account_id I am trying to setup a association between them like so: class User < ActiveRecord::Base belongs_to :account has_many :transactions end class Trans...

i = true and false in Ruby is true?

Am I fundamentally misunderstanding Ruby here? I've been writing Ruby code for about 2 years now and just today stumbled on this... ruby-1.8.7-p249 > i = true and false => false ruby-1.8.7-p249 > i => true Could somebody explain what's going on here please? I'm sure it's to spec, but it just seems counter intuitive to me... ...

Ruby on Rails Join Table Associations

Hey, I have a Ruby on Rails application setup like so: User Model has_and_belongs_to_many :roles Role Model has_many :transactions has_and_belongs_to_many :users Transaction Model belongs_to :role This means that a join table is used called roles_users and it also means that a user can only see the transactions that have been ...

net/http post involving texts to a url using Ruby

Hello all, I am writing a mobile App involving creating a Blogger client. I have the APIs that I need but the problem is how to write the ruby code for making a post using the texts beeing provided as well as making comments. The texts are supplied via form input but I don't know how to write the ruby code to post the text. I will be ver...

I am having trouble with my first project in ruby on rails

Here's my index action in the books controller: http://pastebin.com/XdtGRQKV Here's the view for the action i just mentioned: http://pastebin.com/nQFy400m Here's the result without being logged in: http://i.imgur.com/rQoiw.jpg Here's the result when i'm logged in with the user 'admin': http://i.imgur.com/E1CUr.jpg So the problem is t...

has_many association, nested models and callbacks

Hi! I've got model A and model Attach. I'm editing my A form with nested attributes for :attaches. And when I am deleting all attaches from A via accepts_nested_attributes_for how can I get after_update/after_save callbacks for all of my nested models? Problem is that when I am executing callbacks in model A they are executed right AFTE...

Prawn image position

I'm trying to layout 6 images per page with prawn in Ruby: case (idx % 6) # ugly when 0 : (pdf.start_new_page; pdf.image img, :position => :left, :vposition =>...