ruby

Sphinx, Rails, ThinkSphinx and making some words matter more than others in your query.

I have a list of keywords that I need to search against, using ThinkingSphinx Some of them being more important than others, i need to find a way to weight those words. So far, the only solution i came up with is to repeat x number of times the same word in my query to increase its relevance. Eg: 3 keywords, each of them having a level ...

Get the number between specified strings

Ok. Given the example of: http://example.com/news/3226-some-post-title.html I'm trying to get the 3226. This regexp: http:\/\/interaktywnie.com\/newsy\/(.*).html doesn't seem to work. Please help. Thanks. ...

Rails Notification Message plugin?

I am about to code something for a Rails app of mine and didn't want to reinvent the wheel, hence my question: Do you guys know any Rails Plugin that would allow an application to display notification messages that could be user specific and also allow the user to mark them as "don't show this again"? My vision is to display a top div ...

Error trying to connect to Oracle from Rails on OS X

I went through all the steps described here to set up my OS X machine to allow me to connect to Oracle from a Rails app. Set up the database.yml file in my app: development: adapter: oracle_enhanced host: [SERVER IP ADDRESS] database: [ORACLE INSTANCE SID] username: xxx password: yyy encoding: utf8 Also tried it with the ...

Capistrano & Bash: ignore command exit status

I'm using Capistrano run a remote task. My task looks like this: task :my_task do run "my_command" end My problem is that if my_command has an exit status != 0, then Capistrano considers it failed and exits. How can I make capistrano keep going when exit when the exit status is not 0? I've changed my_command to my_command;echo and i...

Recommendations for Open Source Ruby Encyrption Gem

I need a gem to perform simple string encryption and decryption in Ruby for values I want to store in the database. Can anyone suggest a good open source gem to use for this? ...

Quotation marks turn to question marks ...

So I have a ruby script that parses HTML pages and saves the extracted string into a DB... but i'm getting weired charcters (usually question marks) instead of plain text... Eg : ‘SOME TEXT’ instead of 'Some Text' I've tried HTML entities and CGI::unescape ... but to no avail... did some googling n set $KCODE = 'u' & require 'jcode...

Generate a file list based on an array

Hi all I tried a few things but this week i feel like my brain's having holidays and i need to complete this thing.. so i hope someone can help me. I need to create a filelist based on a hash which is saved into a database. The has looks like this: ['file1', 'dir1/file2', 'dir1/subdir1/file3'] Output should be like this: file1 ...

Ruby Rails collection select is displaying blank "prompt" value?

I have a collection select like the following: <%= f.collection_select :region_id, Region.find(:all), :id, :name, { :prompt => 'Select a State/Province' }, :style => "width: 200px;" %> Sometimes the prompt from the :prompt option appears, but sometimes it does not. Does anyone know where I could begin to troubleshoot this? Maybe I h...

Where can I get Ruby, GraphViz and Dot hosted?

I want to find some hosting for a small Ruby (Sinatra) app that uses Graphviz and Dot. Heroku is usually my favorite because it's a) Free, b) Simple, and c) Scalable. Heroku doesn't do Graphviz and Dot, so I'm looking for an alternative. Any ideas? ...

Get resource name from URL when using a custom controller in Rails

Hi, I have a set of routes that are generated dynamically at runtime, but that all point to the same controller i.e. map.resources :authors, :controller => 'main' map.resources :books, :controller => 'main' These all work fine, producing routes like /authors/1, /books, /books/55, etc and then all end up being processed by the 'main' ...

What is the best way to seed a database in Rails?

I have a rake task that populates some initial data in my rails app. For example, countries, states, mobile carriers, etc. The way I have it set up now, is I have a bunch of create statements in files in /db/fixtures and a rake task that processes them. For example, one model I have is themes. I have a theme.rb file in /db/fixtures t...

How to Write Ruby CGIs on Rails on Windows

I tried just creating a test.rb file putting it in the public directory then calling it like http://localhost:3000/test.rb but that doesn't seem to work. It thinks I'm trying to download the file. What am I missing here? the little script is below: #!/usr/local/bin/ ruby print "HTTP/1.0 200 OK\r\n" print "Content-type: text/html\r\n\r\n...

When i try sudo gem install json I get the following error

I need to install the JSON gem to start my app but I get the error below whenever I try to install the json gem. Can anyone help me out. Im using rails 2.2.2 and gems 1.3.1; thx for any help you can provide. Arions-macbook-pro:.ssh arion$ sudo gem install json Password: Sorry, try again. Password: Building native extensions. This cou...

How do I start the sphinx daemon automatically when my rails application loads?

I am aware of the command to start the sphinx daemon manually. I use a rake task: "rake thinking_sphinx:start" Is it possible to have it start whenever my rails application loads so I don't have to manually type in the command every time? ...

How can I subclass in Shoes?

This is a simple test Ruby Shoes program I am talking about: When I try to use the subclass syntax, like class Hello < Shoes and run my program, it complains 'undefined method para' or 'undefined method stack'. Obviously it is not able to subclass Shoes, hence does not know any thing about 'para' or 'stack' methods. However it runs fine,...

rails ruby-prof and benchmark testing

I'm running Rails 2.2.2. I've read a few articles about ruby-prof and profiling a rails app. And I'm confused as to how things are really working. I was originally using this tutorial http://snippets.aktagon.com/snippets/255-How-to-profile-your-Rails-and-Ruby-applications-with-ruby-prof to profile my app, and it works. This involves...

Active Directory - Django/Rails

I'm thinking about re-writing a web app in Django or Rails and wondering about authenticating against AD. Is one ecosystem better suited for this (libraries, etc) or is it a toss-up? (The app will be hosted on Linux) I have lots of reasons for the re-write, one them is to make myself more marketable. Anyone care to comment on the whic...

Why does this code cause a stack overflow?

The following would cause stack overflow for large 'n', and I can understand why. def factorial(n) (n > 1) ? (return (n * factorial(n - 1))) : (return 1) end Why does the following cause overflow as well? def factorial(n, k) (n > 1) ? (return factorial(n - 1, lambda {|v| return k.call(v * n)})) : (return k.call(1)) end ...

What's the difference between Rack and Rails Metal (Ruby)?

I don't get it! Rack: http://rack.rubyforge.org/ Rails Metal: http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal I read the two articles and my eyes got blurry. How do the two components relate? Examples would be great? ...