# Rails

**URL:** https://www.ruby-forum.com/c/ruby-on-rails/6.md?page=645

[Latest](https://www.ruby-forum.com/latest.md) · [Categories](https://www.ruby-forum.com/categories.md) · [Tags](https://www.ruby-forum.com/tags.md)

**Page:** 646

---

## [AR overzealous type conversion](https://www.ruby-forum.com/t/ar-overzealous-type-conversion/188238)

<div class="topic-metadata">

**Author:** [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Replies:** 0\
**Last updated:** [May 8, 2010, 6:21am UTC](https://www.ruby-forum.com/t/ar-overzealous-type-conversion/188238 "2010-05-08T06:21:24Z")

</div>

Here’s an ActiveRecord oddity. If I call WebPageCache.create(:key =\> \[1, 2, 3\]), AR appears to store a key of \[1,2,3\].to\_yaml even though I have not specified ‘serialize :key’. Is this documented? If not, it feels …

---

## [How to setup gzip rails application](https://www.ruby-forum.com/t/how-to-setup-gzip-rails-application/188236)

<div class="topic-metadata">

**Author:** [@nirosh](https://www.ruby-forum.com/u/nirosh)\
**Replies:** 0\
**Last updated:** [May 8, 2010, 5:22am UTC](https://www.ruby-forum.com/t/how-to-setup-gzip-rails-application/188236 "2010-05-08T05:22:51Z")

</div>

how to setup gzip rails application?

---

## [Can't change "filename" attr "after" Create (attachment\_fu)](https://www.ruby-forum.com/t/cant-change-filename-attr-after-create-attachment-fu/188221)

<div class="topic-metadata">

**Author:** [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Replies:** 1\
**Last updated:** [May 8, 2010, 5:13am UTC](https://www.ruby-forum.com/t/cant-change-filename-attr-after-create-attachment-fu/188221 "2010-05-08T05:13:29Z")

</div>

I know how to change a filename during the upload process using attachment\_fu, however I need to change it after the create based on additional information I don’t have during the initial upload. Performing an attribu…

---

## [How to display error messages for a child resource that failed validation](https://www.ruby-forum.com/t/how-to-display-error-messages-for-a-child-resource-that-failed-validation/187444)

<div class="topic-metadata">

**Author:** [@Matthew\_Hillsboroug](https://www.ruby-forum.com/u/Matthew_Hillsboroug)\
**Replies:** 4\
**Last updated:** [May 8, 2010, 12:10am UTC](https://www.ruby-forum.com/t/how-to-display-error-messages-for-a-child-resource-that-failed-validation/187444 "2010-05-08T00:10:53Z")

</div>

Can anyone explain why this happens? mybox:$ ruby script/console Loading development environment (Rails 2.3.5) \>\> foo = Foo.new =\> #\<Foo id: nil, customer\_id: nil, created\_at: nil, updated\_at: nil\> \>\> bar = Bar.new =\>…

---

## [How to setup gzip on hostmonster](https://www.ruby-forum.com/t/how-to-setup-gzip-on-hostmonster/188224)

<div class="topic-metadata">

**Author:** [@nirosh](https://www.ruby-forum.com/u/nirosh)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/how-to-setup-gzip-on-hostmonster/188224 "2010-05-07T23:52:45Z")

</div>

i need to enable gzip on hostmonster,so could u please anyone help me. thx. nirosh

---

## [Undefined method 'find\_by\_sql'](https://www.ruby-forum.com/t/undefined-method-find-by-sql/188211)

<div class="topic-metadata">

**Author:** [@Mlle](https://www.ruby-forum.com/u/Mlle)\
**Replies:** 1\
**Last updated:** [May 7, 2010, 10:08pm UTC](https://www.ruby-forum.com/t/undefined-method-find-by-sql/188211 "2010-05-07T22:08:33Z")

</div>

Why would I get an undefined method \`find\_by\_sql’ for #Example: 0x981a4e4\> for error when trying to use the find\_by\_sql method in my model? def init\_dictionaries tables = find\_by\_sql( “SHOW TABLES FROM thesaurus” ) …

---

## [Can't eagerly load a polymorphic association defined in an STI parent class?](https://www.ruby-forum.com/t/cant-eagerly-load-a-polymorphic-association-defined-in-an-sti-parent-class/188216)

<div class="topic-metadata">

**Author:** [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Replies:** 1\
**Last updated:** [May 7, 2010, 8:02pm UTC](https://www.ruby-forum.com/t/cant-eagerly-load-a-polymorphic-association-defined-in-an-sti-parent-class/188216 "2010-05-07T20:02:43Z")

</div>

If I define an association (in my case a polymorphic one) in an STI parent class, and try to eagerly load it in a subclass, I get the following error: ActiveRecord::ConfigurationError: Association name ‘myassoc’ was n…

---

## [Error message of a child object](https://www.ruby-forum.com/t/error-message-of-a-child-object/188183)

<div class="topic-metadata">

**Author:** [@oreng](https://www.ruby-forum.com/u/oreng)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 7:46pm UTC](https://www.ruby-forum.com/t/error-message-of-a-child-object/188183 "2010-05-07T19:46:54Z")

</div>

class TranslationKey \< ActiveRecord::Base has\_many :key\_values has\_many :translation\_values, :through =\> :key\_values validates\_uniqueness\_of :name, :message =\> “already exist in another key” end class TranslationVa…

---

## [Using "vanilla model" for find\_by\_sl()](https://www.ruby-forum.com/t/using-vanilla-model-for-find-by-sl/188213)

<div class="topic-metadata">

**Author:** [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 7:22pm UTC](https://www.ruby-forum.com/t/using-vanilla-model-for-find-by-sl/188213 "2010-05-07T19:22:10Z")

</div>

I have several hairy SQL queries that join and select columns from multiple tables. The standard AR pattern: MyModel.find\_by\_sql(hairy\_sql\_query) has rules about which attributes in MyModel are preserved and which a…

---

## [Struggling with accepts\_nested\_attributes\_for](https://www.ruby-forum.com/t/struggling-with-accepts-nested-attributes-for/187942)

<div class="topic-metadata">

**Author:** [@kturner](https://www.ruby-forum.com/u/kturner)\
**Replies:** 7\
**Last updated:** [May 7, 2010, 6:25pm UTC](https://www.ruby-forum.com/t/struggling-with-accepts-nested-attributes-for/187942 "2010-05-07T18:25:15Z")

</div>

Hi, I’ve been struggling with getting accepts\_nested\_attributes\_for to work perfectly with a nested model form. This is a project that was started before Rails 2.0, and I’m trying to use new techniques in the new fu…

---

## [NULL value in CSV fixture, howto?](https://www.ruby-forum.com/t/null-value-in-csv-fixture-howto/188152)

<div class="topic-metadata">

**Author:** [@Owain](https://www.ruby-forum.com/u/Owain)\
**Replies:** 4\
**Last updated:** [May 7, 2010, 5:11pm UTC](https://www.ruby-forum.com/t/null-value-in-csv-fixture-howto/188152 "2010-05-07T17:11:30Z")

</div>

I am preparing some seed data for a deployment from generated a CSV file. However, one of the model’s columns ( child\_id) needs to have a null value in on a few of the rows where there is no Child instance. Whatever …

---

## [Controller Tests fail](https://www.ruby-forum.com/t/controller-tests-fail/186648)

<div class="topic-metadata">

**Author:** [@graham](https://www.ruby-forum.com/u/graham)\
**Replies:** 9\
**Last updated:** [May 7, 2010, 5:05pm UTC](https://www.ruby-forum.com/t/controller-tests-fail/186648 "2010-05-07T17:05:20Z")

</div>

Hi all, I’m hoping someone can help me here I’m trying to carry out functional testing, my IDE is NetBeans 6.8 and I’ve found that any tests on controllers who have to deal with related data are failing. I’ve got a c…

---

## [Server detects change in data](https://www.ruby-forum.com/t/server-detects-change-in-data/188205)

<div class="topic-metadata">

**Author:** [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Replies:** 6\
**Last updated:** [May 7, 2010, 4:50pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205 "2010-05-07T16:50:15Z")

</div>

My fundamental lack understanding of Rails and the architecture of the 'Net wil be demonstrated by the following question: The following is a contrived example: Assume I have several users looking at (identical) scree…

---

## [HTML tag checker](https://www.ruby-forum.com/t/html-tag-checker/188204)

<div class="topic-metadata">

**Author:** [@saurabhpurnaye](https://www.ruby-forum.com/u/saurabhpurnaye)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/html-tag-checker/188204 "2010-05-07T16:22:00Z")

</div>

Hi All, I’m having a text area in my rails application as \<%= f.text\_area :text %\>. User allowed to enter HTML tags in that text area. I’m facing following problems: Not able to check whether the HTML tags entered …

---

## [How to set default cookie domain in Rails3](https://www.ruby-forum.com/t/how-to-set-default-cookie-domain-in-rails3/187974)

<div class="topic-metadata">

**Author:** [@jabulani](https://www.ruby-forum.com/u/jabulani)\
**Replies:** 1\
**Last updated:** [May 7, 2010, 4:14pm UTC](https://www.ruby-forum.com/t/how-to-set-default-cookie-domain-in-rails3/187974 "2010-05-07T16:14:50Z")

</div>

I want to set default cookie domain for my application to “.mydomain.com” to allow cookie session be preserved across subdomains. I use =\> config.action\_dispatch.session = {:domain =\> “.mydomain.com”} in application…

---

## [Reject a nested object if all parameters of its own nested object are blank](https://www.ruby-forum.com/t/reject-a-nested-object-if-all-parameters-of-its-own-nested-object-are-blank/188203)

<div class="topic-metadata">

**Author:** [@Mlle](https://www.ruby-forum.com/u/Mlle)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 3:36pm UTC](https://www.ruby-forum.com/t/reject-a-nested-object-if-all-parameters-of-its-own-nested-object-are-blank/188203 "2010-05-07T15:36:55Z")

</div>

Hello, I have a model called Sample that has many Treatments. A Treatment can have many Results. I want to reject the creation of a Treatment if all its fields are blank and if all the fields of each of its nested R…

---

## [Named\_scopes in deep relations](https://www.ruby-forum.com/t/named-scopes-in-deep-relations/188201)

<div class="topic-metadata">

**Author:** [@jeb](https://www.ruby-forum.com/u/jeb)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 3:15pm UTC](https://www.ruby-forum.com/t/named-scopes-in-deep-relations/188201 "2010-05-07T15:15:16Z")

</div>

Hi, I try to use a named scope for using searchlogic, but I don’t understand how to do in this case: I want to find activities by area\_id Each activity HAS MANY occations Each occation has one location A column in…

---

## [Rails fails to find models in subfolders](https://www.ruby-forum.com/t/rails-fails-to-find-models-in-subfolders/188136)

<div class="topic-metadata">

**Author:** [@f2andy](https://www.ruby-forum.com/u/f2andy)\
**Replies:** 6\
**Last updated:** [May 7, 2010, 3:05pm UTC](https://www.ruby-forum.com/t/rails-fails-to-find-models-in-subfolders/188136 "2010-05-07T15:05:54Z")

</div>

I have my models and controllers set up in sub-folders, so, for example, sample.rb is in app/models/sample\_log, and samples\_controller.rb is in app/controllers/sample\_log. The controllers are defined to be within a na…

---

## [Internal Server Error](https://www.ruby-forum.com/t/internal-server-error/188198)

<div class="topic-metadata">

**Author:** [@karthikeyan](https://www.ruby-forum.com/u/karthikeyan)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 3:05pm UTC](https://www.ruby-forum.com/t/internal-server-error/188198 "2010-05-07T15:05:54Z")

</div>

I often get a web page when ever I try localhost:3000 with the following message: Internal Server Error private method \`gsub!’ called for #Class:0xb6d5d764 WEBrick/1.3.1 (Ruby/1.8.7/2010-01-10) at localhost:3000 I g…

---

## [Nested Models? Creation Order](https://www.ruby-forum.com/t/nested-models-creation-order/187549)

<div class="topic-metadata">

**Author:** [@xavier](https://www.ruby-forum.com/u/xavier)\
**Replies:** 3\
**Last updated:** [May 7, 2010, 2:35pm UTC](https://www.ruby-forum.com/t/nested-models-creation-order/187549 "2010-05-07T14:35:33Z")

</div>

Hi, I am learning Rails and have run into a bit of difficulty with something I suspect is not uncommon, but I’m having difficulty getting my point across to Google. I have three models in an application designed to t…

---

## [Redirect depending on where the action has been triggered](https://www.ruby-forum.com/t/redirect-depending-on-where-the-action-has-been-triggered/188190)

<div class="topic-metadata">

**Author:** [@gregm](https://www.ruby-forum.com/u/gregm)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 1:15pm UTC](https://www.ruby-forum.com/t/redirect-depending-on-where-the-action-has-been-triggered/188190 "2010-05-07T13:15:08Z")

</div>

Hi, I am working on a newsletter module. you can subscribe to the newsletter at many different place on the website and they all trigged the create action on the newsletter controller. I would to redirect to where th…

---

## [Datafeed in rails](https://www.ruby-forum.com/t/datafeed-in-rails/188195)

<div class="topic-metadata">

**Author:** [@miked](https://www.ruby-forum.com/u/miked)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/datafeed-in-rails/188195 "2010-05-07T13:10:33Z")

</div>

Hi, I have to built a search functionality in which whenever the user types “shoes” then my search result will give him an information about the most of online shoppers like (Amazon, ebey) who are selling the shoes w…

---

## [Where are date\_select\_tag?](https://www.ruby-forum.com/t/where-are-date-select-tag/188193)

<div class="topic-metadata">

**Author:** [@k-b](https://www.ruby-forum.com/u/k-b)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 12:08pm UTC](https://www.ruby-forum.com/t/where-are-date-select-tag/188193 "2010-05-07T12:08:33Z")

</div>

Hi! I want a date\_select\_tag inside a form\_tag But it does not work! I looked for the docs at: And even, if I copy the code right inside - there are an error! ActionView::Template::Error (can’t convert Symbol into …

---

## [As\_json not honouring the options hash](https://www.ruby-forum.com/t/as-json-not-honouring-the-options-hash/188192)

<div class="topic-metadata">

**Author:** [@Arpita\_Roy](https://www.ruby-forum.com/u/Arpita_Roy)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 12:03pm UTC](https://www.ruby-forum.com/t/as-json-not-honouring-the-options-hash/188192 "2010-05-07T12:03:17Z")

</div>

I am new to ROR. I have been going through the article regarding as\_json Rails to\_json or as\_json? - Jonathan Julian but i could not make as\_json work with options hash . When i am using as\_json with options, it is no…

---

## [To\_json returning an incorrect format in rails 2.3.4](https://www.ruby-forum.com/t/to-json-returning-an-incorrect-format-in-rails-2-3-4/188194)

<div class="topic-metadata">

**Author:** [@Arpita\_Roy](https://www.ruby-forum.com/u/Arpita_Roy)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 12:03pm UTC](https://www.ruby-forum.com/t/to-json-returning-an-incorrect-format-in-rails-2-3-4/188194 "2010-05-07T12:03:17Z")

</div>

It seems to\_json is returning an incorrect format.I have a Product model with id , title, description. In ProductsController, in index I have def index @products = Product.all respond\_to do |format| format.html # …

---

## [Codegeneration in Model slow](https://www.ruby-forum.com/t/codegeneration-in-model-slow/188187)

<div class="topic-metadata">

**Author:** [@inriz](https://www.ruby-forum.com/u/inriz)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 11:01am UTC](https://www.ruby-forum.com/t/codegeneration-in-model-slow/188187 "2010-05-07T11:01:14Z")

</div>

hello list, i’ve got the following code snippet in my model to generate extra helper functions. def transform\_to\_boolean Property.columns.select {|c| c.sql\_type == "varchar(1)"}.each do |col| define\_method “#{col.…

---

## [Git Issue](https://www.ruby-forum.com/t/git-issue/188166)

<div class="topic-metadata">

**Author:** [@jesse](https://www.ruby-forum.com/u/jesse)\
**Replies:** 2\
**Last updated:** [May 7, 2010, 10:25am UTC](https://www.ruby-forum.com/t/git-issue/188166 "2010-05-07T10:25:31Z")

</div>

Hi All, This is not specifically a Rails question, but I figure that someone here might know enough about git to help me. Here is the situation. I had set up a private Git Repo server for my companies projects. F…

---

## [Using self. Can you newbify this for me?](https://www.ruby-forum.com/t/using-self-can-you-newbify-this-for-me/188107)

<div class="topic-metadata">

**Author:** [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Replies:** 10\
**Last updated:** [May 7, 2010, 9:49am UTC](https://www.ruby-forum.com/t/using-self-can-you-newbify-this-for-me/188107 "2010-05-07T09:49:14Z")

</div>

For some reason I am tripping up on the use of self and new. class LineItem \< ActiveRecord::Base belongs\_to :order belongs\_to :product def self.from\_cart\_item(cart\_item) li = self.new li.product = cart\_item.product …

---

## [Input/output error](https://www.ruby-forum.com/t/input-output-error/188130)

<div class="topic-metadata">

**Author:** [@nitin\_k\_m](https://www.ruby-forum.com/u/nitin_k_m)\
**Replies:** 6\
**Last updated:** [May 7, 2010, 8:54am UTC](https://www.ruby-forum.com/t/input-output-error/188130 "2010-05-07T08:54:01Z")

</div>

Hi My application was running fine. All of sudden I started to get an input/output error in one of the templates. However, error goes away once I restart the mongrel server but after some time again same error appear…

---

## [File.read not working properly for .txt file](https://www.ruby-forum.com/t/file-read-not-working-properly-for-txt-file/188188)

<div class="topic-metadata">

**Author:** [@anubhaw](https://www.ruby-forum.com/u/anubhaw)\
**Replies:** 0\
**Last updated:** [May 7, 2010, 7:19am UTC](https://www.ruby-forum.com/t/file-read-not-working-properly-for-txt-file/188188 "2010-05-07T07:19:29Z")

</div>

Hi All, I am trying to read a .txt file through File.read method. It returns value ‘0004\\0004\\0007\\0005\\0005\\0000\\0001\\0002\\0001\\000\\t\\000A\\000u’. But when i open the file and save it as save as it returns value for …

[Previous page](https://www.ruby-forum.com/c/ruby-on-rails/6.md?page=644)

[Next page](https://www.ruby-forum.com/c/ruby-on-rails/6.md?page=646)
