ruby-on-rails

Adding extension to URL: Rails

I'm setting up some link_to xml views within a rails app. How can the url display the .xml extension? Need it to appear as: http://localhost:3000/test/1-testing.xml Currently it appears as: http://localhost:3000/test/1-testing ...

Rails helper to call remote upon completion of event?

I'm collecting latitude and longitude from Mobile Safari with some JavaScript code. After collecting the information from the browser, I want to update the location with an AJAX request. Is there a helper or otherwise simple way to do this with Rails/Prototype or will I have to do an XMLHttpRequest? I only see link_to_remote, periodicall...

Rails modeling: converting HABTM to has_many :through

I'm doing maintenance work on an existing Rails site and am having some problems stemming from many-to-many associations. It looks like the site was initially built using has_and_belongs_to_many for a few relationships that have since gotten more complicated in the business logic, so I need to use has_many :through instead to support ad...

Rails problem with Delayed_Job and Active Record

I'm using Delayed_Job to grab a Twitter user's data from the API, but it's not saving it in the model for some reason! Please help! (code below) class BandJob < Struct.new(:band_id, :band_username) #parameter def perform require 'json' require 'open-uri' band = Band.find_by_id(band_id) t = JSON.parse(open("http://twi...

RubyCAS-Client question: Rails

I've installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It's working, but I'd like to remove the ?ticket= in the url. Is this possible? ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : http://myapp.com/objects/1?auth%5Fcode=833fe7bdc789dff996f5de46075dcb409b4bb4f0 However it is too long and I think I might be able to "com...

help mongrel wont start

I have decided to switch from Restful authentication to authlogic.. so what I did was delete every file and folder that got installed when I downloaded the plugin.. now when I try to "ruby script/server" I get script/server => Booting Mongrel => Rails 2.3.4 application starting on http://0.0.0.0:3000 /Users/nachof/Sites/unet/co...

Need some input on how to build a large scale text replacement system

My Rails app deals a lot with data from third-party APIs (specifically UPS, FedEx, DHL, etc). What I'd like to do is whenever that data comes in, replace certain phrases with customized phrases. Example: "On FedEx vehicle for delivery" (which we get from the FedEx API), I'd like to replace with "Out for Delivery." Is it best to replac...

Ruby Geolocation Gem/Plugins

What are the available (best) ruby IP-based geolocation gem/plugins? How do they compare to one another in terms of functionality, performance and ease of use (e.g. do they interact with a web service, or require a separate database, etc.) ? I'm hoping anyone that has used some can share their experience and give recommendations. ...

Leaving a large dataset in the test database without reloading

I use cucumber to run integration tests. I have a very large (30,000+ record) stardard setup for testing. How can I leave that in the test.sqlite3 database without re-loading it ever? ...

Searchlogic question

The functionality I'm looking for: I have a form that will search my 'Proposal' model. I want the form to contain a select box and display the categories I have. Now, 'category' is merely a column in my 'Proposal' Model, so the following code from railscasts does not work (as it assumes a category table and use of category_id) <%=...

authlogic rails help

Im trying to set up my app to work with authlogic.. the thing is, other than the fields authlogic is supposed to use I want to keep in my database other attributes Like Name, Last Name, PIN, etc... is there a way to do this? ...

Why would the Net::LDAP gem prevent tests from running?

I have installed the ruby-net-ldap gem version 0.0.4 on my OS X (Snow Leopard) system. When I include the line... config.gem('ruby-net-ldap') in environment.rb, my tests won't run and I get this error... Missing these required gems: ruby-net-ldap You're running: ruby 1.8.6.0 at /usr/local/bin/ruby rubygems 1.3.5 at /Users/et...

Unobtrusive dynamic form fields in Rails with jQuery

I'm attempting to get over the hurdle of dynamic form fields in Rails -- this appears to be something the framework doesn't handle very gracefully. I'm also using jQuery in my project. I have jRails installed, but I'd much rather write the AJAX code unobtrusively where possible. My forms are fairly complex, two or three levels of nestin...

Running system call in rails causes error.

When I try to run the following code: system("pdftk #{@@temp_file_path} output #{@@file_path} user_pw #{@@pass}") I get this error: Permission denied - /tmp/billing.pdf I tried running: chmod +x /tmp But that didn't help. Any suggestions? ...

What is the best way to show my users a preview of email templates in Ruby on Rails?

My software sends emails for users. I want to show them what the emails will look like before they get sent. However, with ActionMailer conventions, the entire template is in one file. This means the html,head,body tags, etc. Can anyone think of a good way to give my users a preview of what the emails I send out will look like? Than...

help with authlogic

I just got done setting up my app to work with authlogic following this exactly before beginning I had already created a products catalog with basic CRUD functionality. Right now I want the products catalog to only be accesible if the user is alread logged in.. so, basically if the user is not logged in it should go to the login page.....

HTML Scraping with Hpricot (Using Ruby on Rails)

hi, I have read a large deal of tutorials to help out and under Hpricot, the problem that i am finding out it is not scraping all the Html so to speak. I'll elaborate: The website i am attempting to scrape html off is http://yellowpages.com.mt/Malta-Search/Radio-In-Malta-Gozo.aspx . I require to obtain the links that are listed as resu...

Ruby on Rails: Finding all "incomplete tasks" through named_scope

Hello, I have two models: (1) Task, and (2) CompletedTask. I'm looking to do a named_scope for :incomplete_tasks (tasks that don't have any entries in the completed_tasks table) I'm thinking it would be something like this in my Task model: named_scope :incomplete_tasks, :conditions => **completed_tasks.empty?** Do you know how I f...

Should a user's profile be a seperate model?

Hi, I'm learning Rails by building a simple site where users can create articles and comment on those articles. I have a view which lists a user's most recent articles and comments. Now I'd like to add user 'profiles' where users can enter information like their location, age and a short biography. I'm wondering if this profile should b...