ruby-on-rails

Showing response time in a rails app.

I want to display a This page took x seconds widget at the bottom of every page in my rails application. I would like x to reflect the approximate amount of time the request spent on my server. What is a good way of doing this? Edit: My production server is on phusion passenger and development environment on mongerel. Would love to ha...

Charset and POST request

Hi All! I have a Rails 2.3.5 application that is working fine with UTF-8 and international characters. Now I have made some integration to a payment gateway where I POST some data, wait a while and get a POST back. The problem is that when I get that post back the international characters are broken. Instead of "sørensen" I get: "søre...

Create a helper or something for haml with ruby on rails

Hello, i am using haml with my rails application and i have a question how the easiest way to insert this haml code into a html file: <div clas="holder"> <div class=top"></div> <div class="content"> Content into the div goes here </div> <div class="bottom"></div> </div> And i want to use it in my haml document like this: %ht...

Delayed_job ID - rails

Example: obj = MyModel.send_later :modelMethod How can I get an ID of the delayed_job inside :modelMethod function? Thx! ...

Rails time zones

I'm calling an external web service API that returns a timezone as listed in the Olson timezones database (e.g. "America/New_York"). However some of the values the API returned are "US/Pacific", "US/Eastern" and apparently don't match any of the Olson timezones in Rails 2.3.2. Can anyone shed some light on this? Thanks in advance for you...

active record helpers defined in ~/.irbrc

I'm really tired of typing my_ar_object.errors.full_messages in my console when i'm testing things... So, I want to define this: module ActiveRecord class Base def err errors.full_messages end end end in my ~/.irbrc so that it is exclusive to script/console. I don't want to define it in some rails initializer since...

Sqs vs SqsGen2 using RightScale right_aws GEM

I'm trying to use the right_aws (1.10.0) GEM with Rails, and I've reduced my problem to a 3-line irb session. The following works require 'rubygems' require 'right_aws' sqs = RightAws::Sqs.new("xxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") while this fails require 'rubygems' require 'right_aws' sqs = RightAws::SqsGen2.new("xxxx...

Outputing value of TrueClass / FalseClass to integer or string/

Hello. I'm trying to figure out if there is an easy way to do the following short of adding to_i method to TrueClass/FalseClass. Here is a dilemma: I have a boolean field in my rails app - that is obviously stored as Tinyint in mysql. However - I need to generate xml based of the data in mysql and send it to customer - there SOAP serv...

Using named pipes in Rails

I need to read and write some data through named pipes. I have tested it in a simple Ruby app, and it works nice. But I dont know, where should i put it in my Rails app? I have heard about Rake tasks, but i don't sure, is it right solution. I need to open a pipe-file, and listen to data. If there is any, i need to process it and make ...

Ruby on Rails not adding record to database

It's been a while since i dipped into Ruby on Rails and i'm having a hard time getting data into my model, here's what the server is saying when i submit my form: Processing ScoresController#index (for 127.0.0.1 at 2010-03-26 15:31:44) [POST] Parameters: {"commit"=>"Add", "authenticity_token"=>"326dd05ffa596bfa12ec3ebb6f48933dbad8dc...

Ruby on Rails website hosting

i want to start a website. it'll be a small community based website. i've learned a fair bit of ruby on rails and am planning to use it. however, i have never deployed a production website before. i've just practiced in my local computer. i wanted to know what are the things i need to deploy the website on the internet. what is the best ...

I can't generate migrations - "illegal route the controller must be specified" - where am I going wrong?

Background: i'm using InstantRails 2.0 I wanted to add a new column to an existing table using the following syntax: ruby script/generate migration add_fieldname_to_tablename fieldname:string So I tried ruby script/generate migration add_invites_to_user invites:integer ruby script/generate migration add_invites_to_users invites:inte...

How do I make an image_tag opaque with Rails?

I have tried the following: <%= image_tag '...path_to_img', :filter => "alpha(opacity=50)" %> But it doesn't work. At least it doesn't create errors, but it doesn't make it opaque, either. I'm rusty on my html/css, and I think from what I've researched so far that the filter/alpha/opacity I tried above is actually css instead of html....

Rails with JQuery DIV manipulation

Say I have a loop of objects (style.cover.pic) in a DIV .style_image <% @styles.each do |style| %> <div class="style_image"> <%=link_to (image_tag style.cover.pic.url(:small)), style %></div> With the use of JQuery On a click event I want to load (this.href) in to the div .style_image which was click not all of the .style_image DIV'...

Rails + MongoMapper + EmbeddedDocument form help

I am working on a pretty simple web application (famous last words) and am working with Rails 2.3.5 + MongoMapper 0.7.2 and using embedded documents. I have two questions to ask: First, are there any example applications out there using Rails + MongoMapper + EmbeddedDocument? Preferably on GitHub or some other similar site so that I can...

Start Sunspot solr at/on Reboot

Hi guys, I'm trying to start Sunspot's solr server on my ubuntu workstation and server. So far I'm tried in the crontab @reboot sh -c 'cd /<location of rails program>/; rake sunspot:solr:start' and @reboot sunspot-solr start -d <options> -s <options> -p <port-num> Neither are able to start the server at reboot. Thoughts? Thanks, ...

How to format JSON date in Javascript?

I'm passing a date from Ruby to Javascript via JSON. It comes into Javascript as "2010-03-24T10:00:00Z". Now, how the heck do I format that in Javascript? ...

How to configure a has_many association with non-ActiveRecord model

My Rails app has a normal ActiveRecord "Account" model stored in the database. The model will store the URL to a remote XML file which defines some other objects. For example, the Account has_many :galleries but the Gallery model is simply defined by nodes in the XML document. So how do I get /accounts/1/galleries to show the galleries...

Email sent by ActionMailer is taking six hours to deliver mail.

So I have been asked to help maintain a website that uses Ruby on Rails. Now, let me just say I've been programming Ruby for awhile but I am still new to Rails. The first problem brought to my attention is how the activation email takes about six hours to arrive. It would be one thing if the email was not being sent due to errors but ...

How do I add a condition to all ActiveRecords Queries for a particular model?

I am using the sentient_user gem to have access to the current_user object in my application. I want to override the default ActiveRecordBase queries to scope them to the current user. For instance, I don't want my users looking at, deleting, modifying other user's orders. I feel like I should be able to override a single (or couple) A...