ruby-on-rails

Trying to install Rmagick on Debian

One of things you need to do to get Rmagick installed apt-get install libmagick9-dev When I try that I get the following errors Reading package lists... Done Building dependency tree... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distributio...

Rails observe_field using jQuery

Is there an equivalent to the Rails/Prototype observe_field method using jQuery without jRails? I am doing a search-as-you-type with will_paginate: <%= observe_field('search', :frequency => 2, :update => 'results', :loading => "Element.show('spinner')", :comple...

Index a boolean field as a string in sphinx

I have a Ruby on Rails site that uses thinking sphinx for searching a postgres database. One of the fields in a table I am searching on is a boolean. I'd like to be able to match on that boolean when a certain keyword is used in the search query. To fully explain with an example: My site is for people who develop their own black and wh...

Multiple database connections in Rails

I'm writing a simpler version of phpMyAdmin in Rails; this web app will run on a web server (where users will be able to indicate the database name, hostname, username, password, and port number of one of the database servers running on the same network). The user will then be connected to that machine and will be able to use the UI to a...

heroku current transaction is aborted

I have a small free app running on heroku. intermittently the app stops working and displays the default heroku error page on the screen. when I check the logs I see the following: ActiveRecord::StatementInvalid (PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block : SELECT * FROM...

Ruby on Rails - Storing application configuration

Hi, I have a relatively simple Rails app and I would like to store various configuration settings that administrator users can change whilst the application is running, for example, allowing comments on posts or changing the display format of the date. I know I can store constants etc in the environment.rb file, however these appear to ...

How to parameterize/transliterate in Javascript?

In Ruby on Rails you can easily convert "any" text into a format which would work for subdomains/pathnames. 1) "I am nobody." -> "i-am-nobody" 2) "Grünkohl is a german word." -> "grunkohl-is-a-german-word" I'd like to do this on the client-side for high responsiveness (alternative would be via Ajax). The last example is called transl...

How to cache an xml file and read its attributes in Rails?

Hello, I have a file that represents all components of a game. I want to load the file into cache on boot, then have the ability to call the attributes of the file from the controllers. How do I begin? ...

Add a form helper method

Ive made a nice editor in jQuery and i want to add it as a form helper method. how would i go about making a new form helper method? ideally id like to be able to call: f.nice_editor :field ...

Rails design doubt: Should/could I load the whole dictionary/table into memory?

I am a newbie working in a simple Rails app that translates a document (long string) from a language to another. The dictionary is a table of terms (a string regexp to find and substitute, and a block that ouputs a substituting string). The table is 1 million records long. Each request is a document that wants to be translated. In a fir...

Ruby on Rails: Initializing instance variables with helpers in view

I'm running into some type of a scope issue that's preventing instance variables from being properly initialized by helpers called from the view. #sample_controller.rb class SampleController < ApplicationController def test end end #application_controller.rb helper_method :display def display if not defined? @display return ...

Don't show application layout on popup window using Rails

I have a rails application using views/layouts/application.html.erb as the default site template. I'm just about to add several popup windows. These shall not inherit and display the application template. How can I exclude several views from loading the application template? Any help would be very appreciated. ...

Selecting and Displaying Columns from Associated Tables in Rails

I am working on developing a skeleton of what to eventually become an administration dashboard. One of the things the dashboard will eventually have to do is allow users to search for users of a game and view information about them. The information about them in question is in different table so naturally I have had to employ associati...

Display data in columns not rows using Ruby on Rails

I would like to display data in Columns rather than Rows in my web page. What is the most efficient way to do this using Ruby on Rails? Many thanks for your help! ...

How can I determine whether a controller action has rendered (rather than redirected?)

The performed? method returns true in a controller if the application has redirected or rendered. How can I determine whether the application rendered (rather than redirected)? Judging from the performed? docs, I can look at @performed_render, but this seems hacky. Edit: Why do I want to do this? I'm trying to cache the output of a c...

rails lazy load of model attributes

Hi! Normally rails loads data with a :select => "*" from the database. I know I could change this. But I'd like to go another way: always only select "id" and load the attributes automatically later on when they are needed. Example: accessing user.description should if it's been loaded yet. if not, trigger a "SELECT description FROM us...

Keep track of reserved URLs (to enable vanity per-user URLs)

On my rap lyrics explanation website, every user has an associated "favorites" page at http://rapgenius.com/USERNAME Because these favorites pages occupy the root namespace, I have to make sure that no one takes a username that I'm already using for something else. E.g.: /songs /lyrics /users /posts How can I look up all top-level p...

Response time increasing (worsening) over time with consistent load

Ok. I know I don't have a lot of information. That is, essentially, the reason for my question. I am building a game using Flash/Flex and Rails on the back-end. Communication between the two is via WebORB. Here is what is happening. When I start the client an operation calls the server every 60 seconds (not much, right?) which results i...

Convert code from PHP to Ruby on Rails

I'm trying to use geoip's web service for a ruby on rails application. They don't give any ruby demos but this is what they give for PHP. I was wondering if anyone knew how to convert this to work on ruby on rails? I only need the city and the region from the data. More examples can be found at their site at $query = "http://geoip3...

Problem after submitting a form.

I'm new at ruby on rails and I built a form with a list with checkboxes inside. I asked here how to get the checked values with params and I got it to work. The idea now is to perform some action with the selected items if I click some button, and if I click another one then perform anoother action, but always staying at the same page af...