ruby-on-rails

Complex associations in ActiveRecord models

I'm trying to understand how ActiveRecord deals with associations that are more complex than simple has_many, belongs_to, and so on. As an example, consider an application for recording music gigs. Each Gig has a Band, which has a Genre. Each Gig also has a Venue, which has a Region. In the rough notation of MS Access (which I'm sudd...

Rails POST, PUT, GET

After I generate a scaffold, Rails gives me the ability to POST to items.xml which will create a new item. A GET to items.xml will simply list them all. Where does Rails specify which method in the controller (create or index, respectively) will be called, based on the type of action I am performing? More specifically, POST calls method...

Complex relationships in Ruby - display data across many tables

Hi, I have designed an application consisting of 20+ tables, and utilizing Ruby on Rails. I am using an authentication system for users to login. I want to display to the user, when he logs in, information related to him that can be found across many tables, between these tables there are all the possible relationships. How can I accomp...

Ruby on Rails / Yellow Maps For Ruby Plugin woes...

Okay I've read through the plugin comments and the docs as well and I have yet to come up with an answer as to how to do this. Here's my problem I want to use the :info_window_tabs and the :icon option, but I don't know what format to pass my information in. According to the documentation the following code should be correct. Here's my c...

How do you issue a 404 response from a rails controller action?

What's the preferred way to issue a 404 response from a rails controller action? ...

SQL to search many to many relationship with acts_as_tsearch

I'm using the acts_as_tsearch plugin for rails to do full text searching with Postgresql. They give an example of multi table search here: http://code.google.com/p/acts-as-tsearch/wiki/ActsAsTsearchMethod But that only does a one-to-many relationship. I'm trying to get it to also search a many-to-many relationship (has_and_belongs_to_...

usage of find_by_sql to delete record

I'm trying to delete few records from table 'abc' where id is fetched from 'xyz' table SQL: delete from abc where id in (select ids from xyz where i= 10) this query i want to execute using find_by_sql to avoid multiple hits to database. It's giving error. Please help me in getting this delete action done in a single hit to DB. ...

can't modify frozen string

I'm using the following code in the view which I got from http://www.igvita.com/2006/10/20/adding-social-bookmarks-in-rails/ This is the pastie code But I get the following error: TypeError in Pages#show Showing app/views/pages/show.html.erb where line #26 raised: can’t modify frozen string Extracted source (around line #26): 23: Tw...

Gems slowing down Rails test startup, can I selectively disable these?

I have a terrible Rails test startup time. When running a single functional test that may take 2 seconds to run, the total time from execution to returning to the command line could be up to 10-15 seconds. There are two gems I know are definitely getting in the way. A Facebook and Flickr gem (Facebooker, Flickraw). Facebooker will al...

Rails: Generating Tables based on groups of related database records

I have a collection of records in my database that I want to print out to separate tables based on the record date. So I already have the following (in Haml, fyi): %table %tr %th Name %th Type %th Total Hits - for record in @records %tr{ :class => cycle('odd','even') } %td= record.name %td= record.target...

Is there a default english translation file for Active Record?

I am upgrading an application a rails application to 2.3.2 and I am finding that I can't display the default validation error messages for ActiveRecord because I don't have a translation file for it. This is the error that is reported: translation missing: en-US, activerecord, errors, template, header translation missing: en-US, active...

Problem sending post request from Flex app to Ruby on Rails back end

I am having trouble getting my flex app to send a POST request to my Rails app. It seems to always send GET. This is my service declaration: <mx:HTTPService id="add_email_service" showBusyCursor="true" result="parseJoinResult();" fault="onJoinFault(event)" useProxy="false" /> In my application init function, I set the method to PO...

Why is Ruby BigDecimal returning a weird value?

Hi, I am writing code that will deal with currencies, charges, etc.. I am going to use the BigDecimal class for math & storage. We ran into something weird with it, however. Using this statement: 1876.8 == BigDecimal('1876.8') it returns false. If I run those values through a formatting string "%.13f" I get: "%.20f" % 1876.8 => ...

How should I track widget renders?

I created a widget that users of my site will embed on their web sites. I want to track the amount of times a widget renders as well as the referring URL. The widget was written in flex and my back end is Rails. One obvious way to do this would be to have my widget make a service call to the back end to register a hit. However, when ...

Ruby on Rails and CruiseControl.rb

How do I set up the email notification with CruiseControl.rb? I've specified the ActionMailer::Base.smtp_settings in the site-config.rb but where do I specify who will receive the email notification? Do I need to create a config.xml file? If so, where do I put the file and do you have an example of the contents of this file? ...

Problem installing googlecharts gem?

I am trying to use the googlecharts gem to create some quick charts. Here are the rubyforge and github sites: http://googlecharts.rubyforge.org/ http://github.com/mattetti/googlecharts/tree/master After installing, I keep getting an error saying "no such file to load -- googlecharts" even though when I do a "gem list", the gem is list...

Ruby on Rails. How do I use the Active Record .build method in a :belongs to relationship?

I have been unable to find any documentation on the .build method in Rails. (I am currently using 2.0.2) Through experimentation it seems you can use the build method to add a record into a :has_many relationship before either record has been saved. for example Class Dog :has_many :tags :belongs_to :person end Class Person :h...

Is it possible to run Ruby on Rails with Ruby 1.9x?

If so, how? When you go to http://rubyonrails.org/download, it says: We recommend Ruby 1.8.7 for use with Rails. Ruby 1.8.6, 1.8.5, 1.8.4 and 1.8.2 are still usable too, but version 1.8.3 is not. ...

Nested insert_html bug : Ruby On Rails & Javascript

Hey everyone! This problem is driving me absolutely insane! It seems like a bug in the rendering of JS by Rails but I'm not sure. Brief synopsis: I'm attempting to create a RELEASE which has_many TRACKs. These TRACKS have many TRACK_LINKS. These TRACK_LINKs then have associated TRACK_LINK_TYPEs (mp3, m3u, podcast, whatever). Think of ...

Good way to handle inline-edit form using Rails and jQuery

I have a list of items, being displayed in a series of DIVs. When someone clicks on an "edit" link, I want to replace the div with a form that will let them edit the contents of that item in a nice way. I'm trying to think of the ideal way to handle this. Do I create a hidden edit form for every item in the list, and hook the edit link ...