ruby-on-rails

Rails Uninitalized Constant Error on Startup

Hi there, I have a local development machine which has started to give me the following error on starting up the Rails server: C:/Software/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/i nflector.rb:404: uninitialized constant ActiveSupport::CoreExtensions::String (N ameError) from C:/Software/Ruby/lib/...

Heroku and Rails 3 beta

How to deploy rails 3 beta project on heroku? When I try to do it I get this error: -----> Heroku receiving push -----> Gemfile detected, running gem bundle ! Heroku push rejected, "gem bundle" failed, please check your Gemfile for errors. ...

I have ambiguous routes or need to supply additional parameters

I have: in config/routes.rb map.resources :projects do |project| project.resource :privacy end end in models/project.rb belongs_to :privacy in models/privacy.rb has_one :project in show.html.haml = change_privacy_button(@project) in an accessible helper def change_privacy_button(project) button_builder...

Xmpp4r pubsub with gmail

I've got my xmpp server with which I intend to publish messages to my subscribers on the gmail server. I am able to get those messages when the subscriber belongs to my jabber server but when I try to publish messages the google users are unable to get the message. However I am able to fetch the messages using the pubsub.get_items_from(...

How to pass more than one argument to a worker at backgroundrd

Hello! I'm trying to pass a list of arguments to a backgroundrb in documentation it says: MiddleMan.worker(:billing_worker).async_charge_customer(:arg => current_customer.id) but it only works for just one argument, I tried these but none worked for me args => [1,2,3] args => {:t=>"t", :r=> "r"} any ideas how to solve this?? ...

How to implement a subscription based DB, such as basecamp

I have developed a fully functional ruby-on-rails application which utilizes numerous mysql tables. I would like to turn this into a subscription based service but I have some general, probably basic, conceptual questions: In a setup such as Basecamp does each user have access to her/his own (as in unique) db tables or are the tables s...

Upgrade Path from Globalize 1 for Rails 2.3.x Apps

A couple of years ago, I started using Globalize (Version 1) for my app (over 1500 translated strings and 3 locales). Since then a couple of other i18n frameworks for Rails appeared, i18n from Sven Fuchs and Globalize 2. Unfortunately, none of those are anywhere close (call) compatible with the syntax of the Globalize 1 framework. Is t...

Why can't I create my database using "rake db:create"?

I've recently started reading up on Rails and while getting my development environment ready on Windows, I kept running into problems. So I opted to just work on the server space I have with asmallorange.com. Everything went smoothly until I tried created my database. When running rake db:create I get a response saying that it coul...

Are there any easy instructions for migrating from Phusion Passenger to Unicorn?

I am running into deployment issues with Phusion Passenger on a fairly large app: stalled processes on high loads, idle processes, slow firing up of an instance, etc. So I was looking into Unicorn, which I like very much from an architecture/performance perspective. Are there any easy to follow migration guides to go from Nginx Phusion...

What is the opposite of url_for in Rails? A function that takes a path and generates the interpreted route?

Hi there, Brain's a little fried....How do I get a hash of the :controller and :action from a relative_path? This is basically the opposite of url_for. in the example below, "some_function" is the mystery function name I'm looking for...I know it's easy, just can't remember or seem to be able to find it in the docs. Like so: some_fun...

Does spec tests migrate dbs on every test?

I did rake test:prepare and clone the db. Then when I do spec spec/controllers/file, it migrates the db every single time. Is that supposed to do that? I thought it was only supposed to migrate the dbs once. Thanks ...

need help with DB design - Rails way

I'm new to rails and need some help with DB design. It is basically category, product, quantity, price...type of tables. I have 4 categories: CatA CatB CatC CatD Each category above will have multiple products in them: CatA - ProductA1, ProductA2, ProductA3 CatB - ProductB1, ProductB2, ProductB3 CatC - ProductC1, ProductC2, ProductC...

Can I incorporate prototype.js into an FBML facebook application?

we have a lot of existing code in a web application that we want to use in a facebook application. Much of it on the client side depends on prototype.js. Can I incorporate prototype.js into my FB application without difficulty, and am I going to have to make a choice about iFrame vs FBML early on? ...

List Entry and Display Best Practice

I have an application where when users sign up they get to choose the day of the week they would like to describe. Each User has a mondaysub, tuesdaysub, etc (all strings) to store whether or not they are to receive an email on those days. For some other reasons, I need to keep it so that f or t mark in each column to designate subscribe...

How to set rails_env for a script or batch file

I put my batch file in lib folder and use rails db configuration, active-record like this. require "#{File.dirname(__FILE__)}/../config/environment.rb" class Batch def hello Message.new do |t| t.title = "hello" t.save end end end batch = Batch.new batch.hello when excute batch ruby lib/batch.rb in developm...

Rails: what is the “correct” (idiomatic) way to pass a parameter from new to create in a RESTful controller?

I have a very common situation and a solution, but I would like to ask the Rails experts out there if it can be improved. I have a very typical RESTful controller where the user supplies some of the object attributes upon creation. There is a thing model, a ThingsController and various views, including new, create, and a _form partial. ...

looping through a bunch of DB changes in a Rails project

I have a Import function which takes a bunch of data in xml format and pastes it into my db. The problem is, that depending on the amount of data that process can take quite a long time. I see in the server log, that there are incredible lots of sql statements beeing executed do save back all the data. How can I improve performance for ...

How can I transparently modify an ActiveRecord method in a model?

I have a model with UUIDs stored in BINARY(16) field in a MySQL table. I would like to be able to transparently convert hexadecimal uuid into binary for the setter method and back when I use the getter method. what is the 'right' way to proceed? ...

Ruby on Rails: How do you check if a file is an image?

How would you check if a file is an image? I'm thinking you could use an method like so: def image?(file) file.to_s.include?(".gif") or file.to_s.include?(".png") or file.to_s.include?(".jpg") end But that might be a little inefficient and not correct. Any ideas? (I'm using the paperclip plugin, btw, but I don't see any methods to ...

Want to use 1 rails app for multiple sites/domains

I have a client who needs the same custom CMS developed for about 5 apps. All apps will have a "similar" but different look and feel and I'd really like to have 1 rails application handle this and just modify the layout/views as needed. Is there a gem/plugin or a precedent for this? ...