ruby

unicorn_rails ignores unicorn.rb directives when started from launchctl?

I'm having trouble getting unicorn to launch correctly using launchctl. I have a Rails application on my macbook pro. It runs fine under Passenger, but I'd like to switch over to unicorn to test it out. I have the following unicorn.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ...

Why is ruby not so popular in linux scripts comparing to python

Can you please explain me, why despite of great ruby popularity for web applications thanks to rails framework it is still not used or very rarely used by linux users to create system apps/scripts. We can compare it to python, witch not only has django and others for web applications, but is also commonly used as scripting language in li...

Rake trouble finding MySQL after uninstalling Rails 3.0.0

So I thought I had fixed the problem posted in this question and I uninstalled Rails 3.0.0 with sudo gem uninstall rails -v 3.0.0, but then I had troubles with other things. I took rogerdpack's advice to a different level and uninstalled all of my ruby gems and mysql, then reinstalled them. Now I get the following: Icarus:temporary atg...

Why doesn't Ruby support i++ or i-- for fixnum?

The pre/post increment/decrement operator (++ and --) are pretty standard programing language syntax (for procedural and object oriented languages, at least). Why doesn't Ruby support them? I understand you could accomplish the same thing with += and -=, but it just seems oddly arbitrary to exclude something like that, especially since...

Rails 3 run_callbacks method

Hey guys, I'm playing around with the new Rails 3 API and I have a question regarding the new method run_callbacks(kind, *args, &block) In the following code: class User < ActiveRecord::Base before_save :say_hi after_save :say_bye private def say_hi; puts "hi"; end def say_bye; puts "bye"; end end I can explicit cal...

PDFKit middleware problem on Rails 2.3.8

I have installed PDFKit and wkhtmltopdf on my Ubuntu 8.04 server. I am trying to use PDFKit as middleware in my Rails 2.3.8 app and have added the following lines to environment.rb (as directed on the jdpace pdfkit page): require 'pdfkit' config.middleware.use PDFKit::Middleware My Mongrel seems to start up but as soon as I request a p...

changing version number in newgem

I'm using newgem to manage my gem and according to the readme you just change the version in the top level file of the gem name. However rake gem is not picking up the gem version i am specifiying. module mygem VERSION = "0.0.1.beta1" end when i run the rake task rake gem it builds '0.0.1', not 0.0.1.beta1 is there a rake argument ...

after_find callback broken after upgrade to rails3

Grettings! In an app that was working flawlessly in Rails 2.3.8 i have the following class method: def self.encode(*attr_names) encoder = Encoder.new(attr_names) before_save encoder after_save encoder after_find encoder define_method(:after_find) { } # defining here, since there's only alias in the Encoder class i...

Mongodb crashed! Where has my data gone?

Please help! Mongodb crashed on my server. When I started the mongod backup I have no data in database! Looking at the data/db/ directory I have the following 5 files: mongo.lock production-mongodb 4k production-mongodb.0 64m production-mongodb.1 128m production-mongodb.ns 16m I think mongo has somehow started a new...

how to require active record working outside of rails

i need to require active record, but I am working outside of rails (here is why: Simple Ruby Input Validation Library). do I need to require the entire rails gem, or can i be DRYer? ...

Basic Ruby SQL Problem Error undefined method `[]'

I think I'm being stupid. rc = Mysql.new('CENSORED_HOST','username','password','db') release = rc.query('select * from wp_ribcage_releases where release_id = 1 limit 1') puts release["release_title"] rc.close And I am getting the following error: ribcage-connect.rb:17: undefined method `[]' for #<Mysql::Result:0x1011ee900> (NoMetho...

How do I create a blacklist/whitelist for finding Rails model records?

I want to create a model, "Whitelist" to build a list of users that I do not want displayed in my main model, "User". Example Controller def index @users = User.find(:all) #These are to be filtered behind the scenes in the model end Example Model class User ActiveRecord::Base has_many :whitelist def self.find #Add somethi...

Validating a Rails model against an external API

Consider the following scenario: You have an account model You have an external service which manages subscriptions (such as CheddarGetter). You do not want to create a customer on CG unless the data entered passed your own validations, and likewise you don't want to save the customer down to your own database unless CG accepts the cus...

Speeding up RSpec tests in a large Rails application

I have a Rails application with over 2,000 examples in my RSpec tests. Needless to say, it's a large application and there's a lot to be tested. Running these tests at this point is very inefficient and because it takes so long, we're almost at the point of being discouraged from writing them before pushing a new build. I added --profile...

Why do I always need "ruby" in front of "script/runner"??

When I do just script/runner it gives me -bash: script/runner: Permission denied When I do sudo script/runner it gives me sudo: script/runner: command not found It only works when I do ruby script/runner. Why? Everywhere else I see people just run script/runner without the ruby in front of it... Is there a "fix" for this? It's causing ...

How to delete part of a CSV string using Ruby?

Hi, I have a string: "116,118,120,130" and will want to delete either the first, last or any value in between upon execution. To to this I was using: "116,118,120,130".gsub('118','') but the problem is the string contains an extra unnessesary comma: "116,,120,130" and if I use "116,118,120,130".gsub(',116','') it will remo...

Ruby error: "Symbol as array index"

Hi, I am writing a spec for the create method of a controller : describe "POST create" do it "should create an adtag with valid params" do campaign = Campaign.make campaign_attributes = Hash.new campaign_attributes[:adtag_attributes] = Hash.new campaign_attributes[:adtag_attributes][:code] = "<h1>Sample co...

Remove older versions of Ruby (on Windows)

I just downloaded Ruby 1.9.2, and I want it to completely replace the older version of Ruby (1.8.7) that I also have installed. (Mostly because I get confused when installing things with different versions floating around.) What's the best way to do this? Do I uninstall the older version? (If so, how?) Can I just replace the old ruby1.8...

Simple Conversion Of String To UTF-8 in Ruby 1.8

I know that in Ruby 1.9 you can easily re-encode a string like this. s = s.encode('UTF-8') What is the equivalent in Ruby 1.8? What require lines does it need. All the tutorials I have seen are needlessly complicated and I don't understand what is going on. Cheers! ...

Textmate Rails3 no such file to load — bundler

When I try to run tests from TextMate in Rails3 i get an error that I trace back to boot.rb. When I try to run boot.rb via textmate I get this error: LoadError: no such file to load — bundler method gem_original_require in custom_require.rb at line 31 method require in custom_require.rb at line 31 at top level in boot.rb at line 4 ...