ruby-on-rails

Under what conditions would I want to set a different application-level timezone in rails?

In almost every environment.rb, there's a line for config.time_zone = 'UTC'. What exactly does this line do, and under what circumstances would I want to change it (to, e.g., config.time_zone = 'EST')? ...

Rails -- How to save HTML output of a HAML partial as a string to send to an external service?

Hey guys, first post here, hope you can help me out. We're generating a newsletter automatically every 24 hours using a rake task. There's a section at the top of the newsletter where an admin can put a customized message. The screen that the admin uses has a live preview of the newsletter (they were insistent on this), rendered using...

OAuth vs. Portable Contacts for importing contacts

We are currently using an outdated screen scraper gem to import contacts from gmail/yahoo/etc. I want to update this to use the new OAuth based APIs so users don't have to enter their credentials on our site. I'm really intrigued by the work Plaxo is doing with Portable Contacts which Google also supports. It feels like that is a good...

Help me understand joins in ruby on rails

Warning, I am new to ruby on rails. I know my database isn't setup all that great, but we're pulling in from a remote database and storing information from that database. Users: - id - ... stations - id - user_id - hex_key (unique) - ... calls - id - reported by (hex key from stations) - data source id (from remote databas...

Copy model instances in Rails

I have a model Foo with attributes id, name, location. I have an instance of Foo: f1 = Foo.new f1.name = "Bar" f1.location = "Foo York" f1.save I would like to copy f1 and from that copy, create another instance of the Foo model, but I don't want f1.id to carry over to f2.id (I don't want to explicitly assign that, I want the db to ha...

ruby on rails id not saving

I know this is going against ruby on rails conventions, but my id of this table doesn't need to auto-increment and I'm setting it through the logic. However, it's not saving to the database. Everything getting saved is saving as null for the id. def self.up create_table :probes, :id => false do |t| t.string :id t.string :name t.i...

Why do users have to enter a 7-digit twitter PIN to grant my application access?

I am implementing some ruby on rails code tweet stuff for my users. I am creating the proper oauth link...something like http://twitter.com/oauth/authorize?oauth_token=y2RkuftYAEkbEuIF7zKMuzWN30O2XxM8U9j0egtzKv But after my test account grants access to twitter, it pulls up a page saying "You've successfully granted access to . Simpl...

Paperclip, large file uploads, and AWS

So, I'm using Paperclip and AWS-S3, which is awesome. And it works great. Just one problem, though: I need to upload really large files. As in over 50 Megabytes. And so, nginx dies. So apparently Paperclip stores things to disk before going to S3? I found this really cool article, but it also seems to be going to disk first, and then do...

Why does this rails query behave differently depending on timezone?

I have a rails time-based query which has some odd timezone sensitive behaviour, even though as far as I know I'm using UTC. In a nutshell, these queries give different answers: >> Model.find(:all,:conditions=>['created_at<=?',(Time.now-1.hours).gmtime]).length => 279 >> Model.find(:all,:conditions=>['created_at<=?',(Time.now-1.hours)])...

Is a billing address required by PayPal's Website Payments Pro?

I'm creating a website with rails that sells a virtual service, and therefore don't really want to validate the billing address for credit card transactions. From what I have read on paypal (page 14 of this pdf) and other resources i have looked at, this should be totally possible. However, when I submit a purchase or an authorize re...

Foreign Keys and Multi Model forms in Rails 2.3 - Bug or feature?

I am playing with making a blog. I would like to have several types of entries (a link to an interesting site + brief comment, a traditional blog post with title and body text, a picture... you get the idea). The idea seemed straight forward. An entry table/model with a the few details common to all those types (creation time and a litt...

What's the difference between example.com/controller and example.com/controller/ in Rails?

Hi there, I have a PostsController, not essential to the example but will help when I paste snippets, and I'm using current_page? to, as the name implies, figure out what page is being displayed. I'm getting what seem like weird results. current_page? will return different answers if I go to /posts vs. /posts/. As a test, on the index...

What can I do to speed up Rails development mode?

Rails, on development mode is SLOW. Very, very slow. I run Vista, and I set config.cache_classes = true in development.rb... But, it's still slow and I have to restart the server after I change my code. My coworker develops Rails on a Mac and sees similar slowness. My development time slows down significantly because it takes minutes ...

technology recommendation for LAN Dashboard

I'm about to start a fairly large project for a mid-sized business with a lot of integration with other systems (POS, accounting, website, inventory, purchasing, etc.) The purpose of the system is to try to reduce current data siloing and give employees role-based access to the specific data entry and reports they need, as well as to rep...

What is the difference between mock and mock_model in RSpec

I've recently came across different tutorials, where people use both mock and mock_model functions. In RSpec tutorial for controllers they use the mock_model function, but right in the documentation of RSpec, there is only mock function, but no mock_model I tried to run some tests myself, and I didn't find any real difference, since ev...

Additive Chaining with named_scope

Is there a way to combine scopes in an additive fashion? If I have the scopes User.big_haired and User.plays_guitar I can call User.big_haired.plays_guitar and get all the users who have big hair AND play guitar. Can I write this to get all users who have big hair OR play guitar? I guess I have to add that I realize that you ...

10001 Internal Error when trying to capture an authorization from PayPal with Activemerchant

I've successfully made authorized a card, and it shows up in my sandbox transaction log. When I try to capture using that authorization (with activemerchant, which uses SOAP), this is the XML it sends to the server: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w...

Rails routing and before filter question

Hi all, lets say i have the following relationship: class Event < ActiveRecord::Base has_many :tickets end class Ticket < ActiveRecord::Base belongs_to :event end And I have a route like this: map.resources :events, :has_many => :tickets map.resources :tickets And i have a before filter like this on tickets_controller: be...

Ruby web service

I am new to Ruby. I am having trouble passing the parameters to a web method. factory = SOAP::WSDLDriverFactory.new('https://api.affili.net/V2.0/Logon.svc?wsdl') driver = factory.create_rpc_driver driver.Logon(...) How can I pass in the required parameters? I have tried passing in an array, but the paramters are made nil, I tried cre...

How to uninstall Passenger (mod_rails) from nginx?

I've a running nginx and Ubuntu 8.09 site running a rails app -- but we are not making use of Peassenger anymore and it seems to take up a lot of memory. I google around and there's tons of info on how to install Passenger, but I didn't find any on uninstalling. ...