ruby-on-rails

Rails - I need a checkbox to change a field in the DB

I know I have done this before, but for the life of me I can't figure it out. I have a table with a "called" field in it. I need to use a checkbox to update the db and check if "called" is "true" or not. Doesn't need to be AJAX, just needs to update the field. table: rsvp field: called Thanks a ton. ...

Retrieve all options from select tag after submitting

Hello, I have a slight problem with getting the options within the select tag. Some background information; This is a report, and as such the select options will vary depending on what is stored on the DB depending on some conditions. So, I'm using observe field to get the selected option, BUT, I need to get all the options because I...

When I rename a column, how do I ensure my views aren't referencing the column by the old name in my test suite?

I encountered a situation where I've renamed a column, but was unaware that my views were still referencing the column by the old name. This broke my web app, and I pushed these changes to my production server, thus learning the importance of a test suite. I'm new to testing, so, I'm wondering: how I can catch problems caused by this k...

MySQL 'Too many keys' error

I'm creating a MySQL table in Rails which has about 170 boolean fields, each of which needs to be searchable and hence indexed, but when I create the indexes I get the error message: To many keys specified; max 64 keys allowed Is this limit hard coded or is there a config switch I can flip which wold get around it? Or do I need to re...

Rails plugin to clean up (reformat) html output?

Is there any plugin (gem) that after rendering page can clean and reformat it? By cleaning I mean removing unnecessary new lines and whitespaces. ...

rails polymorphic association (legacy database)

I am using a legacy database, so i do not have any control over the datamodel. They use a lot of polymorphic link/join-tables, like this create table person(per_ident, name, ...) create table person_links(per_ident, obj_name, obj_r_ident) create table report(rep_ident, name, ...) where obj_name is the table-name, and obj_r_ident is ...

Rails join three models and compute the sum of a column

Hi, I need some help over here to understand how the model relationship works on rails. Let me explain the scenario. I have created 3 models. Properties Units Rents Here is the how relationship mapped for them. Model #property.rb class Property < ActiveRecord::Base has_many :units has_many :rents, :through=> :unit ...

How to get the row numbers when I using render in RoR?

I use this code to generate the td tag format: <%= render(:partial => "cart_item", :collection => @cart.items) %> And this is the _cart_item.html.erb: <tr> <td class="column-left"><%=h cart_item.title %></td> <td> x <%= cart_item.quantity %></td> <td class="column-right">$ <%= cart_item.price %></td> </tr> But I want t...

Rails Complex nested form - random issue

I know this is a complete long shot, but I thought I would give it a try. I have an issue when submitting an extremely large nested form to the update action. This issue is completely random, and when it happens I can not get it to reoccur even using the same dataset from when it happened. When the issue happens it seems that the parame...

Big SQL SELECT performance difference when using <= against using < on a DATETIME column

Given the following table: desc exchange_rates; +------------------+----------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | time | datetime | NO | MUL | NULL | | | base_currency | varchar(3) | NO | MUL | NUL...

How do I change an attribute value in a model?

I have the following script ActiveRecord::Base.establish_connection(:adapter => 'mysql', :database => 'development', :username => 'appAccount', :password => '------', :socket => '/tmp/mysql.sock') class ProcessQueue < ActiveRecord::Base end The tutorial I'm using claims the following should work. updateQ = ProcessQueue.find(:all, :...

Can I modify RoR CRUD behavior?

I know that the RoR CRUD is very easy to use. But I want the generate program do something special that normal CRUD. I don't want "Delete" in my apps, all the record only can make as "delete" instead of actually delete. So, I want to add a column -- "status" automatically when the Create is generated, and I want to change the "Delete" be...

Problem with Insoshi install script and mysql

hi Guys, i have a problem regarding the installation of Insoshi. I followed the insallation instructions in the Readme file of Insoshi. My problems occur when i try to run "script/install" The readme file says, that when the script fails, there is something wrong with the database configuration in the database.yml file. But i checked i...

RoR remember state in partial renderer

Hi, how can I remember some state within a partial renderer? Problem at hand: my partial _testitem.html.erb renders table rows of a collection of testitems. A Testitem has an id and a sortkey and the partial is called with <%= render :partial => "testitem", :collection => @testbox.testitems.sort_by{|x| [x.sortkey, x.id]} %> i.e. all ...

How to send facebook session details to a rails application using facebooker plugin

Hi, I am not able to integrate the iPhone application with my rails application both using fbconnect as the session details that i send along with the request from iPhone are not recognized by the facebooker plugin. The request from iPhone is as follows: [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost...

Ruby Rical Timezone problem.

I'm using Ruby Rical to basically generate an icalendar as a response to an original icalendar specifing that I'm attending (accepting) the invitation. I can generate the response correctly but I'm having a problem with timezones, basically if I let RiCal infer the correct Timezone, it works correctly depending on the TimeZone String sp...

Best Linux Distro for Ruby on Rails?

After a bad experience trying to get even the simplest Rails application running at Lunarpages, I'm moving to Slicehost. Does anyone have an opinion as to which of their Linux distros to use for a fairly high-traffic Rails site? They offer CentOS, Debian 5, Fedora (10 to 12), Gentoo, Red Hat EL 5, and Ubuntu (8 and 9). While we're on ...

Rails - Catch 'Invalid Authenticity Token' exception

I'm currently using RESTful Authentication plug-in on my rails application. There is a typical scenario when a user stays at login screen for enough time (let's say 1 day..) that makes the authentication token invalid due to time expire. When this user tries the next day to login (he didn't refresh, he is still with this invalid token...

Sorting/Paginating/Filtering Complex Multi-AR Object Tables in Rails

I have a complex table pulled from a multi-ActiveRecord object array. This listing is a combined display of all of a particular user's "favorite" items (songs, messages, blog postings, whatever). Each of these items is a full-fledged AR object. My goal is to present the user with a simplified search, sort, and pagination interface. The ...

rails remove old models with migrations

I have a bunch of rails models that i'm re-writing into a single model to simplify my code and reduce unnecessary tables. I'm wondering what the best way to delete a model class and its table is. I want past migrations to still succeed, but I don't want to leave the empty models lying around. Do I have to manually delete the old mig...