ruby

Stackoverflow-like login system in Rails?

What's the best (easy) way to implement a login/authentication system on a Rails web-app that looks and works like the Stackoverflow system? I realize that it's basicly OpenID, but Stackoverflow handles integration with multiple providers. Is there a easy way to this on Rails? Or do we have to hack restfull_auth or authlogic to do that...

Did test server port change in Rails 2.3?

I upgraded rails to 2.3.2 from 2.1.1 yesterday and a bunch of my tests started failing. When I was running under 2.1.1, the test server was running on port 3000 so I had a HOST_DOMAIN variable that included the port - HOST_DOMAIN = "localhost.tst:3000". This is so my assert_redirected_to's would succeed. Now, however, it seems that th...

How do I find an open source Ruby project to work on?

Should I just go to SourceForge and try to find something that looks interesting by doing a search? Or is there a Ruby-specific website that helps you to find open source projects to contribute to? After you find it one, do you usually just send an email to the project owner to see if you can help or do you just start submitting code to...

What's the best way to create a static page in Rails?

I've created some resources in my Ruby on Rails application: localhost/admin/books localhost/admin/users localhost/admin/... Now I want to create a static page which just contains links to these resources and is accessible from localhost/admin I've tried to create the page in /public/admin/index.html and it works, but unfortunately I...

What open source Ruby OR Rails project would increase your appeal to a potential employer?

Now that I know how to find a Ruby open source project, how do I judge which ones are most likely to help my career prospects. I've never worked in the Ruby world and need something that might show off my potential to be a good hire. Or is any project as good as anything else as long it's something you're interested in? Also, would it ma...

How to setup and work with RoR Complex Joins?

This code is taken from a previous question, but my question directly relates to it, so I've copied it here: class User < ActiveRecord::Base has_many :group_memberships has_many :groups, :through => :group_memberships end class GroupMembership < ActiveRecord::Base belongs_to :user belongs_to :role belongs_to :group end class...

Simplest way to validate an input against a file of words?

What is the best way to validate a gets input against a very long word list (a list of all the English words available)? I am currently playing with readlines to manipulate the text, but before there's any manipulation, I would like to first validate the entry against the list. ...

Get route for base class of STI class in Rails

Say I have a rails app with 3 models, Person, Place and Thing. Say the Thing uses single table inheritance, so there are FancyThing and ScaryThing subclasses. Then there are routes defined with map.resources :people, :places, :things. So there are no controllers for FancyThings and ScaryThings, the ThingsController handles either type...

Ruby: How to make IRB print structure for Arrays and Hashes

When I make a new array/hash in irb, it prints out a nice format to show the structure, ex. ["value1", "value2", "value3"] {"key1" => "value1"} ... but when I try to print out my variables using puts, I get them collapsed: value1 value2 value3 key1 value1 I gather that puts is not the right command for what I want, but what is? I ...

Valid email address regular expression?

I have done some testing but I wanted to ask if anyone sees a problem with this ruby regular expression for email validation: /\A([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\Z/i Look good? Thanks, Tony ...

How can i 'insert' a small ruby app into Ruby on Rails to make a web page?

I have a small ruby application that I made on my local machine. It uses a text file insted of a database. It's a simple app that takes in a word, processes it against the text file, and then outputs the results using puts. I would like to fit it into a RoR framework, hosted on my personal machine. I have run through some lessons and ...

How to best create an xml map of recursive directory listing in rubyonrails?

I want to build an XML map of all directories and files in my public/catalogs rails directory.(recursive map) I would like it to be constructed with basic <directory> <file> element with name attribute equal to the dir or file name. <catalogs> <file name="index.html"> <directory name="foo"> <file name="file1.html" /> <directo...

PHP developer learning Ruby and Ruby on Rails

I have been interested in learning Rails for some time now and feel now is as good as time as ever to dip in and actually get my hands dirty. I've spent the past week reading every free ebook on Ruby and Ruby on Rails I can find. I just finished reading Ruby Essentials. I have also been playing with http://tryruby.hobix.com/ I have ins...

ActiveRecord running different queries in production?

I have a class hierarchy looks like this: class Post < ActiveRecord::Base; end class Project < Post; end class ProjectDesignWall < Project; end There's a controller that fetches data like so: @projects = Project.find(:all, :include => [:project_image_photos,:user]) In development, this runs the following query, straight from the lo...

Group results created at a similar timestamps

In my project I would like to select records from my database and then group them together by those that occurred at a similar time to the latest record within a certain time range. For example, with a 1 hour time range. If a user created 3 posts between 4:30pm and 5:15pm, 2 posts between 1:15pm and 1:30pm, and 1 post at 10:00am I would...

Anything like SciPy in Ruby?

Looking further into the differences between Python and Ruby, is there a Ruby equivalent to SciPy, or what other scientific math gems are available for Ruby? ...

Linking Two Models Together in Ruby on Rails

I've been stuck on this all day. I have a setup like the one below. I'm trying to define friends using the group_memberships association. class User < ActiveRecord::Base has_many :group_memberships has_many :groups, :through => :group_memberships has_many :friends # what goes here? << end class GroupMembership < ActiveRecor...

How to generate Ruby documentation using different template?

I want to generate the Ruby documentation with hanna template. How to do that? Or where can I download it if it's available at all? Using rdoc -o ~/doc --inline-source --line-numbers --format=html --template=hanna gives me docs with missing methods. It seems like it doesn't generate methods written in C. ...

Browse field

How can I choose a file from a file browse dialog (i.e., uploading a file from my PC) in a Ruby Selenium automation script? ...

Ruby: Can't save document with Libxml-ruby

From the libxml-ruby API docs (http://libxml.rubyforge.org/rdoc/index.html), under LibXML::XML::Document, I tried the following: filename = 'something.xml' stats_doc = XML::Document.new() stats_doc.root = XML::Node.new('root_node') stats_doc.root << XML::Node.new('elem1') stats_doc.save(filename, :indent => true, :encoding => 'utf-8') ...