ruby

Heroku app throws "Internal Server Error"

This app works just fine on my local computer. After pushing it to Heroku, static pages appear to be working but the blog section throws an Internal Server Error. I pulled the logs by running "heroku logs" and this is what I get: ==> production.log <== /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:i...

Ruby and RSS2 Feed not displaying image

Trying to create a simple RSS2 Feed that I could later pass on to FeedBurner but can't get RSS feed to display images at all. Also, from what I have read having xml.instruct! on top might cause IE to complain it's not a valid feed. Is this true? My Code looks like xml.instruct! xml.rss "version" => "2.0", "xmlns:dc" => "http://purl...

Rails 'possible_controllers' problem

What I'm trying to do is pretty simple: generate a list of permissions based on controllers action defined roles. This works pretty nicely, the only problem, is that when I try to generate the list of rails controllers a second time (note: the first time works flawlessly) using: ActionController::Routing.possible_controllers I get a...

parsing # in rails uris

i am getting the following url information and need to parse it within rails. i already checked request and params but it is not there. the "#" character seems to f*ck up things. here's the url: http://foo.bar.me/whoo#access_token=131268096888809%7C2.5BRBl_qt4xJ08n88ycbpZg__.3600.1276880400-100001151606930%7C0kJ1K-qoGBbDoGbLx6s4z5UEa...

Multiple has_manys of the same model

I have these models: Person has_many :messages_form_person, :foreign_key => :from_user_id, :class_name => :messages has_many :messages_to_person, :foreign_key => :to_user_id, :class_name => :messages Message belongs_to :to_person, :foreign_key => :to_user_id, :class_name => :person belongs_to :from_person, :foreign_key => ...

Rails: Link changes one attribute and then goes back

Rails newbie here. I have a list of items which can have a status represented by an integer (right now its just 1=active 0=inactive). What I want is next to each item a link to change the status of that item. So it might look like this: A nice item - Enable Another pretty item - Disable I can't think of how to make the link...

How does instance_eval work and why does DHH hate it?

At about the 19:00 mark in his RailsConf presentation, David Heinemeier Hansson talks about the downsides of instance_eval: For a long time I ranted and raved against instance_eval, which is the concept of not using a yielded parameter (like do |people|) and just straight do something and then evaluate what's in that block ...

Thinking_sphinx sorting through associations

I am trying to sort the search results of a thinking_sphinx search. The columns I want to sort are in associated tables: class Membership < ActiveRecord::Base define_index do indexes :title indexes user.first_name, :as => :first_name indexes user.last_name, :as => :last_name has :organization_id, :active set_property...

using thin for long-polling connection

since it's threadless, would the ruby-based thin be okay? ...

rails custom validation :on => :create not working

I have a "custom" validation method that I only want executed on create like: validate :post_count, :on => :create def post_count # validate stuff end but it gets fired on update (in addition to on create). Does the :on => :create symbol not work with "custom" validation methods? THanks! ...

Automating Web Access and Watir

I'm building a Ruby program that uses several other programs, and while most of them are programs I can download and run on this computer, one has to be accessed and run through a web browser. I actually have two questions: I've found Watir which looks like a good web automation tool, but it's meant for testing. Is it still okay to use ...

How do I write this `method_missing`?

I have a class Wrapper that supports adding options that you can then look up later. It stores these options in an internal hash @dict. w = Wrapper.new w.foo # => NameError w.foo = 10 w.foo # => 10 How can I write a method_missing for Wrapper so that I can support nested calls on @dict? w = Wrapper.new w.foo.bar.baz = 1000 w.foo.bar....

How to detect a process ending with Ruby open3

If I run open with: input, output,error = Open3.popen3 "nikto -host someip -port 80 -output xml" How can I detect if nikto is done? It takes a while for the scan to complete. If something goes wrong, I suppose I have to periodically check error to see if anything that been written? Is there any decent docs that exist for open3? No, t...

Ruby-Git g.status always fails

I have been trying to use the ruby-git gem to make commits etc from with in a ruby script however the method to check the current status always throws an error. My understanding is that this code, although not doing too much, should be valid. #gem install git require 'rubygems' require 'git' g = Git.init g.status but it returns: ...

What does cPanel actually do to create a Rails app?

I am wondering what actually happens behind the scenes on the server when I create a Ruby on Rails application through the cPanel interface. Is it just calling $ruby script\generate $ruby script\server Or is there more to it? ...

Can a Rails app launch a rack app?

If I have a Ruby on Rails application running on my Apache shared server (with Mongrel), can I get it to launch/run another total separate Rack application? Then could I possibly build a Rails app that manages other rails/rack apps? So it could tell what apps are running and start/stop them when I want. Or is each app trapped in it's ow...

What's the best way to use yajl-ruby with my Rails project?

Rails 2.3.6 started using the fast new json library, yajl-ruby, "if available". In the "JSON gem Compatibility API" section of the yajl-ruby readme it outlines a method to just drop in yajl-ruby inclusion and have the rest of the app seamlessly pick it up. So, ideally, I'd like Rails to use it My gems to use it My application code to...

Mechanical Turk: Post file to externalSubmit interface?

I have setup my own custom form for mechanical turk and am posting to their external interface. <form enctype="multipart/form-data" action="https://workersandbox.mturk.com/mturk/externalSubmit" method="post" name="mturk_form" id="mturk_form"> <p> <label for="turk_task_image_image">Upload an image</label><br> ...

How to bundle a ruby package into an [Objective-C] cocoa application?

I'm trying to figure out how I could bundle a package, written in Ruby (Sass) into a Cocoa application (Objective-C, not Ruby Cocoa) for me to execute (via NSTask is fine, unless there is an easy way to bridge ObjC<->Cocoa that I'm not aware of). The Sass package is something you have to install, using "gem install" or "rake install" --...

Detect encoding

I'm getting some string data from the web, and I suspect that it's not always what it says it is. I don't know where the problem is, and I just don't care anymore. From day one on this project I've been fighting Ruby string encoding. I really want some way to say: "Here's a string. What the hell is it?", and then use that data to get it ...