ruby

monit with delayed_job set up.

I have done all this modification to setup monit and delayed_job. I have create one file delayed_job.monitrc in my app/current/config. delayed_job.monitrc check process delayed_job with pidfile /home/sysadmin/app/current/shared/pids/delayed_job.pid start program = "/usr/bin/env RAILS_ENV=production /home/sysadmin/app/current/scrip...

In Rails/ActiveRecord 3, how do I change the default primary key type for MySQL?

In Rails 3, how do you change the default primary key type to, say, BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY In my case I'm only interested in MySQL. For Rails 2, you can see the answer to "How do I use long IDs in Rails?"1 In Rails 3, however, this will throw an error. I'm not sure if that's because the class is no long u...

Can't Join a model when using belongs_to

class Exercise < ActiveRecord::Base belongs_to :user end class User < ActiveRecord::Base has_many :exercises end Why can't I find all Exercises there were created by users with the role of "admin"? Exercise.first :include => [:user], :conditions => ['user.role = "admin"'] The error shoes that the users table is not being join...

Sharing a session between Ruby and PHP

Is it possible to share a session between my PHP app on a subdomain and my Ruby apps on my other subdomains? I don't really know where to take it from here. I know I can manually set the domain to the root one so that the cookie is valid for all the subdomains, but how would I get/set stuff from/to the session so that it's shared across...

How do I write a method for multiple controllers that strips out an array of text?

I want to write a method that simplifies the names of corporations. I would like it to work as follows: @clear_company = clear_company(@company.name) What would happen is @company.name = "Company, Inc." @clear_company would be "Company" If @company.name = "Company Corporation" @clear_company would be "Company" There wouldn't be ex...

jekyll - plugins support - how does it work?

I've just found this comment from mojombo: The latest on master now has Plugin support. Look at lib/jekyll/converters for examples of how they're done. Also, any *.rb files in a _plugins directory will be loaded so that you can create custom plugins of your own. I've had a look /lib/jekyll/converters but could not understand how th...

mongodb and mongomapper

hi i have a rails app that currently uses activerecord to store and query products. Each product has a category and sub category and each sub category is defined by multiple field that i can create within the application. From this when a user wants to input a specific product, they are pressented with the relevent form fields. This ...

How to search the pre and post part of the word using Thinking_sphinx gem on rails

Hi, I have created my search part successfully with the thinking_sphinx gem and I have searched a word it is showing correct, But the problem with the search is it need full word to be given to search exact match. I dont want to give exact word instead any particular character or part of words also be taken into account. help me to s...

how to keep my infrequently used programming language skills in shape

I use ruby infrequently - usually it adds up to writing a script once in two months or more. I do most of my programming with C++, which is very different from ruby. with such wide gaps between my brushes with ruby I keep forgetting basic aspects of the language (like parsing a text file and other simple stuff). I would like to d...

Getting low rails mongrel requests per second (8-15 per second)

So I have tried this out on multiple computers with multiple setups (servers/apps) and I seem to consistently get Rails completing 8-15 requests per second even for doing selects on empty tables with 1 field. I think I'm doing something wrong here because I've read a lot of stats online where people are getting 60-200 with mongrel. So be...

Theoretically speaking, I can use IronRuby to write all apps that c# can write, right?

Hi guys, I know some ruby language. Now I need do some .net development. I don't want to learn a new language. So, after googling I got IronRuby. Now my question is Can I use IronRuby to write all apps that c# can write? Thanks. ...

ruby dynamic method passing a value

How do I pass a value to a dynamic method name that's called on a rails model? @model.send(dynamic_method_name.to_sym,123) This gives the error: wrong number of arguments (1 for 0) If I were to use the same method like this though: @model.post_id = 123 then it works. So there is a "setter" method for the method post_id (and t...

What is the 'etc' ruby gem for?

I was looking through some code and came across a "require 'etc'" line. Of course, googling for things like "ruby etc gem" has been fruitless. I haven't found any documentation for it (yet) so I thought I'd ask here. ...

Ruby equivalent of PHP’s mcrypt_encrypt() function

Is there a Ruby equivalent of PHP’s mcrypt_encrypt() function ...

How do I do multiple lines of Ruby in html.erb file

Hey, I'm using Ruby on Rails and need to run a block of Ruby code in one of my html.erb files. Do I do it like this: <% def name %> <% name = username %> <%= name %> or like this: <% def name name = username %> <%= name %> Thanks for reading. ...

How to code Ruby equivalent of PHP’s mcrypt_encrypt() function

If I write the following code mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $raw, MCRYPT_MODE_CBC, $iv); How to write in ruby? ...

Storing arrays in database using ActiveRecord

I am on rails 2.3.8 & I am using mysql as db adapter. I want to store arrays in my database. After searching I could come up with this very useful article. Now I need to use GUI for input & not only server console. So say I have a text field called nums which logically should have int array. What should be the format of nums so that it...

A ruby method to replace "="

Hi, I want to eliminate "=" sign for a particular reason. It might looks like this: cat_that_has_name("Kelly").as(:kelly) kelly.do_something The "as" method here is used to generate a method "kelly" that reference my cat. Could anyone help me with this? Any suggestions will be appreciated. Update: Jorg was right, I've add a simple...

the ferret error in rails project

I use the plugin of acts_as_ferret. when i use find_with_ferret,i got this problem.I got the error messages from the console like this EOFError in 'DestroysController save destroy require reason' End-of-File Error occured at <except.c>:117 in xpop_context Error occured in store.c:216 - is_refill current pos = 0, file length = 0 T...

Selenium rc open only the remote control windows an does not display the second browse

I have selenium server 1.03 runing on Ubuntu 9.10 with FF 3.5.3. I use the following code : require 'selenium/client' .... @selenium = Selenium::Client::Driver.new \ :host => "10.0.215.3", :port => 4444, :browser => "*firefox", :url => "http://www.google.fr/", :timeout_in_second => 5 .... .... @selenium.start @selenium.set_co...