# Rails

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

[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:** 1019

---

## [Replace\_html with action template](https://www.ruby-forum.com/t/replace-html-with-action-template/161043)

<div class="topic-metadata">

**Author:** [@dimi3](https://www.ruby-forum.com/u/dimi3)\
**Replies:** 1\
**Last updated:** [February 23, 2009, 9:31am UTC](https://www.ruby-forum.com/t/replace-html-with-action-template/161043 "2009-02-23T09:31:14Z")

</div>

Hello All, I am trying to replace\_html with an action template, not a partial. Currently I don’t know how do it, I’ve renamed all my action to have \_ in their names and I don’t like this approach. I’ve tried render :…

---

## [Use data from multiple tables in one view](https://www.ruby-forum.com/t/use-data-from-multiple-tables-in-one-view/161021)

<div class="topic-metadata">

**Author:** [@mattmcswain](https://www.ruby-forum.com/u/mattmcswain)\
**Replies:** 6\
**Last updated:** [February 23, 2009, 8:46am UTC](https://www.ruby-forum.com/t/use-data-from-multiple-tables-in-one-view/161021 "2009-02-23T08:46:06Z")

</div>

Thanks for help in advance with this. I have been trying to understand how to get this to work correctly and I have been having trouble getting it to work the way that I think it should. I would like to have somethin…

---

## [How to invalidate the model caching in ruby?](https://www.ruby-forum.com/t/how-to-invalidate-the-model-caching-in-ruby/161078)

<div class="topic-metadata">

**Author:** [@vikas](https://www.ruby-forum.com/u/vikas)\
**Replies:** 0\
**Last updated:** [February 23, 2009, 8:38am UTC](https://www.ruby-forum.com/t/how-to-invalidate-the-model-caching-in-ruby/161078 "2009-02-23T08:38:56Z")

</div>

Hello All, I used rails caching to cache the model as in model language.rb file def self.cached\_languages return Rails.cache.fetch(‘languages’) { Language.all } end Now I want to add/delete some new language to dat…

---

## [Format.html and redirect\_to](https://www.ruby-forum.com/t/format-html-and-redirect-to/158813)

<div class="topic-metadata">

**Author:** [@Ricky](https://www.ruby-forum.com/u/Ricky)\
**Replies:** 4\
**Last updated:** [February 23, 2009, 8:25am UTC](https://www.ruby-forum.com/t/format-html-and-redirect-to/158813 "2009-02-23T08:25:00Z")

</div>

I was wondering what the purpose of wrapping a redirect\_to in a format.html block is. I get why you’d want to do this with a render, but if you’re redirecting the browser to another URL, what’s the point? As I underst…

---

## [ActiveRecord::AssociationTypeMismatch](https://www.ruby-forum.com/t/activerecord-associationtypemismatch/161073)

<div class="topic-metadata">

**Author:** [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Replies:** 1\
**Last updated:** [February 23, 2009, 8:17am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch/161073 "2009-02-23T08:17:23Z")

</div>

I have 2 models: mop, has\_and\_belong\_to\_many :contacts contact, has\_and\_belong\_to\_many :mops when I save my mop Ii have the users coming in a an array: \[“9”,10"\] I am doing this to asscociate each one to a mop: @co…

---

## [I18n Rails version compatibility?](https://www.ruby-forum.com/t/i18n-rails-version-compatibility/161071)

<div class="topic-metadata">

**Author:** [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Replies:** 1\
**Last updated:** [February 23, 2009, 6:53am UTC](https://www.ruby-forum.com/t/i18n-rails-version-compatibility/161071 "2009-02-23T06:53:42Z")

</div>

Hi, I just want to know whether i18n is compatible with Rails-2.1 I am a newbie in rails, i heard of globalisation plugin also. So which one is the best to work with and if any other suggestions, i would appreciate t…

---

## [About nested resources](https://www.ruby-forum.com/t/about-nested-resources/160943)

<div class="topic-metadata">

**Author:** [@difei](https://www.ruby-forum.com/u/difei)\
**Replies:** 6\
**Last updated:** [February 23, 2009, 5:35am UTC](https://www.ruby-forum.com/t/about-nested-resources/160943 "2009-02-23T05:35:12Z")

</div>

Hi all, I have several resources: map.resources :articles, :has\_many =\> \[:comments\] map.resources :movies, :has\_many =\> \[:comments\] map.resources :photos, :has\_many =\> \[:comments\] all of them have a nested resource …

---

## [Storing just the year in the DB](https://www.ruby-forum.com/t/storing-just-the-year-in-the-db/160925)

<div class="topic-metadata">

**Author:** [@daborg69](https://www.ruby-forum.com/u/daborg69)\
**Replies:** 9\
**Last updated:** [February 23, 2009, 3:28am UTC](https://www.ruby-forum.com/t/storing-just-the-year-in-the-db/160925 "2009-02-23T03:28:18Z")

</div>

Hey, This may be a simple question, but I just wanted to make sure I was doing it right. I need to store just the year in my database - i.e. vacation entitlement year = 2008 Should I store it using ‘date’ and leave …

---

## [CHECK if param exists? please help](https://www.ruby-forum.com/t/check-if-param-exists-please-help/161041)

<div class="topic-metadata">

**Author:** [@dnstevenson](https://www.ruby-forum.com/u/dnstevenson)\
**Replies:** 6\
**Last updated:** [February 23, 2009, 3:27am UTC](https://www.ruby-forum.com/t/check-if-param-exists-please-help/161041 "2009-02-23T03:27:42Z")

</div>

hi folks. i want to check if a param exists if not to set it to a default value for my date range filter. in my controller i have: @from\_date = Date.strptime(params\[:startdate\],"%d/%m/%Y") @to\_date = Date.strptime(pa…

---

## [How to get the ID of the object I just saved in the DB?](https://www.ruby-forum.com/t/how-to-get-the-id-of-the-object-i-just-saved-in-the-db/161055)

<div class="topic-metadata">

**Author:** [@loader](https://www.ruby-forum.com/u/loader)\
**Replies:** 4\
**Last updated:** [February 23, 2009, 3:01am UTC](https://www.ruby-forum.com/t/how-to-get-the-id-of-the-object-i-just-saved-in-the-db/161055 "2009-02-23T03:01:34Z")

</div>

Hello everyone! Does the method save return the ID ? Because i’m doing this : if @post.save flash\[:notice\] = ‘Post was successfully created.’ end and I need the ID of the post I just created. I think it could work …

---

## [Help w/ rake db:migrate error](https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971)

<div class="topic-metadata">

**Author:** [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Replies:** 3\
**Last updated:** [February 23, 2009, 1:06am UTC](https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971 "2009-02-23T01:06:43Z")

</div>

I made a few changes to my migration files, dropped all tables (rake db:drop:all), and when I went to re-create everything (rake db:migrate), I get this: rake db:migrate --trace (in /Users/Eric/Development/Work/Rails…

---

## [Tests failing for models with string primary key](https://www.ruby-forum.com/t/tests-failing-for-models-with-string-primary-key/158648)

<div class="topic-metadata">

**Author:** [@zaczheng](https://www.ruby-forum.com/u/zaczheng)\
**Replies:** 2\
**Last updated:** [February 22, 2009, 11:23pm UTC](https://www.ruby-forum.com/t/tests-failing-for-models-with-string-primary-key/158648 "2009-02-22T23:23:57Z")

</div>

Hi, My tests(rspec) are failing on models that has a String primary key. Rails wrongly creates the test table with the primary key in Integer format. As a result, the fixtures can not be imported, nor does relationsh…

---

## [Is it possible to use restful\_authentication as a gem?](https://www.ruby-forum.com/t/is-it-possible-to-use-restful-authentication-as-a-gem/161042)

<div class="topic-metadata">

**Author:** [@vince](https://www.ruby-forum.com/u/vince)\
**Replies:** 0\
**Last updated:** [February 22, 2009, 7:44pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-use-restful-authentication-as-a-gem/161042 "2009-02-22T19:44:39Z")

</div>

I’m starting a new project and was about to install restful\_authentication as a plugin when I noticed on GitHub - technoweenie/restful-authentication: inactive project that there is now a restful-authentication.gemspe…

---

## [Problem with test\_truth](https://www.ruby-forum.com/t/problem-with-test-truth/160990)

<div class="topic-metadata">

**Author:** [@jobber](https://www.ruby-forum.com/u/jobber)\
**Replies:** 10\
**Last updated:** [February 22, 2009, 7:33pm UTC](https://www.ruby-forum.com/t/problem-with-test-truth/160990 "2009-02-22T19:33:57Z")

</div>

hello all, i have a problem with test\_truth. require ‘test\_helper’ class MyDataTest \< ActiveSupport::TestCase def test\_truth assert true end end this should ok without failures or errors. but it failure: Error: …

---

## [Model test](https://www.ruby-forum.com/t/model-test/161035)

<div class="topic-metadata">

**Author:** [@arshak](https://www.ruby-forum.com/u/arshak)\
**Replies:** 1\
**Last updated:** [February 22, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/model-test/161035 "2009-02-22T19:30:59Z")

</div>

Hello, I have a before\_validation\_on\_create callback on one of my models. It works fine when I run it through the console in dev/prod but in test (also going against mysql) it doesn’t seem to fire. Anything special …

---

## [Why can't to\_xml read my mind?](https://www.ruby-forum.com/t/why-cant-to-xml-read-my-mind/160982)

<div class="topic-metadata">

**Author:** [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Replies:** 5\
**Last updated:** [February 22, 2009, 6:47pm UTC](https://www.ruby-forum.com/t/why-cant-to-xml-read-my-mind/160982 "2009-02-22T18:47:32Z")

</div>

Railsters: I suspect the answer is “because they invented it before inventing eager loading”. The first minor issue with to\_xml’s refusal to read my mind is it’s not DRY (like my mind!): Model.all(:include =\>{ :thi…

---

## [Help to make a SaaS](https://www.ruby-forum.com/t/help-to-make-a-saas/161032)

<div class="topic-metadata">

**Author:** [@Eder\_Gobbi](https://www.ruby-forum.com/u/Eder_Gobbi)\
**Replies:** 0\
**Last updated:** [February 22, 2009, 5:00pm UTC](https://www.ruby-forum.com/t/help-to-make-a-saas/161032 "2009-02-22T17:00:42Z")

</div>

Hi, I’m not a programmer, but i have an great idea about developer a SaaS with Ruby to use Twitter as base… this project can be great sucess. If you believe, reply! \[\]sss Eder Gobbi

---

## [How to add javascript directly to the view](https://www.ruby-forum.com/t/how-to-add-javascript-directly-to-the-view/161018)

<div class="topic-metadata">

**Author:** [@scudco](https://www.ruby-forum.com/u/scudco)\
**Replies:** 6\
**Last updated:** [February 22, 2009, 4:44pm UTC](https://www.ruby-forum.com/t/how-to-add-javascript-directly-to-the-view/161018 "2009-02-22T16:44:27Z")

</div>

Im incorporating ajax / javascript stuff for the first time in my project and im a bit confused by all various methods available, rjs, prototype, javascript etc so please excuse me if this is an obvious question. Whi…

---

## [Using after\_filter to remove image after render](https://www.ruby-forum.com/t/using-after-filter-to-remove-image-after-render/161029)

<div class="topic-metadata">

**Author:** [@naevity](https://www.ruby-forum.com/u/naevity)\
**Replies:** 0\
**Last updated:** [February 22, 2009, 3:41pm UTC](https://www.ruby-forum.com/t/using-after-filter-to-remove-image-after-render/161029 "2009-02-22T15:41:00Z")

</div>

Hi Everyone, I tried doing this and it’s not working as I would expect it, but I’m not sure if it’s even possible. I have an app that generates and image on request and displays it to the user. To cut back on storage,…

---

## [Running console commands in rails](https://www.ruby-forum.com/t/running-console-commands-in-rails/161023)

<div class="topic-metadata">

**Author:** [@Stewart](https://www.ruby-forum.com/u/Stewart)\
**Replies:** 1\
**Last updated:** [February 22, 2009, 1:29pm UTC](https://www.ruby-forum.com/t/running-console-commands-in-rails/161023 "2009-02-22T13:29:37Z")

</div>

Hey, how can i run console commands form my rails app. I have tried using backticks. eg result = svn checkout \<url\> \<path\> They work fine when i run the sciprt from the command line with ruby something.rb but when …

---

## [Cant seem to run rails console](https://www.ruby-forum.com/t/cant-seem-to-run-rails-console/161024)

<div class="topic-metadata">

**Author:** [@Stewart](https://www.ruby-forum.com/u/Stewart)\
**Replies:** 1\
**Last updated:** [February 22, 2009, 1:26pm UTC](https://www.ruby-forum.com/t/cant-seem-to-run-rails-console/161024 "2009-02-22T13:26:05Z")

</div>

Hello, I cant seem to run my console. I get the following error ~/workspace/testtube $ ./script/console Loading development environment (Rails 2.2.2) /usr/local/ruby\_test/lib/ruby/site\_ruby/1.8/i686-darwin9.6.0/ rea…

---

## [Adding custom validations to active record](https://www.ruby-forum.com/t/adding-custom-validations-to-active-record/161011)

<div class="topic-metadata">

**Author:** [@sa125](https://www.ruby-forum.com/u/sa125)\
**Replies:** 3\
**Last updated:** [February 22, 2009, 12:56pm UTC](https://www.ruby-forum.com/t/adding-custom-validations-to-active-record/161011 "2009-02-22T12:56:07Z")

</div>

Hi - I want to add my own validation to a rails app, and need help making it global to my app. Basically, the validation makes sure a number is positive - I found this code on the at http://snippets.dzone.com/posts/sh…

---

## [Error\_messages\_for](https://www.ruby-forum.com/t/error-messages-for/160974)

<div class="topic-metadata">

**Author:** [@giga](https://www.ruby-forum.com/u/giga)\
**Replies:** 2\
**Last updated:** [February 22, 2009, 12:42pm UTC](https://www.ruby-forum.com/t/error-messages-for/160974 "2009-02-22T12:42:02Z")

</div>

Is it possible to print error message near the inputbox and not all on top of the page by \<%= error\_messages\_for ‘users’ %\> So if I have user registragion form and there ara inputs: username password password\_confir…

---

## [Q: find\_by\_x\_id and named scopes](https://www.ruby-forum.com/t/q-find-by-x-id-and-named-scopes/161012)

<div class="topic-metadata">

**Author:** [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Replies:** 2\
**Last updated:** [February 22, 2009, 12:15pm UTC](https://www.ruby-forum.com/t/q-find-by-x-id-and-named-scopes/161012 "2009-02-22T12:15:03Z")

</div>

Hi I have a model Topic that has many Posts, and I’m trying to use a named scope on my find I can do something like this: @posts = @topic.posts.named\_scope\_func But I cannot do this: @posts = Post.find\_by\_topic\_id(…

---

## [Mysql error unknown column 'columns.user\_id'](https://www.ruby-forum.com/t/mysql-error-unknown-column-columns-user-id/161004)

<div class="topic-metadata">

**Author:** [@kenle545](https://www.ruby-forum.com/u/kenle545)\
**Replies:** 2\
**Last updated:** [February 22, 2009, 12:02pm UTC](https://www.ruby-forum.com/t/mysql-error-unknown-column-columns-user-id/161004 "2009-02-22T12:02:45Z")

</div>

Had this error when trying to add comments to another user’s photo. ActiveRecord::StatementInvalid in User photosController#show Mysql::Error: Unknown column ‘comments.user\_id’ in ‘on clause’: SELECT photos.id AS t0\_r…

---

## [Trailing slashes in URLs causing routing errors in 2.3.0 RC1](https://www.ruby-forum.com/t/trailing-slashes-in-urls-causing-routing-errors-in-2-3-0-rc1/161014)

<div class="topic-metadata">

**Author:** [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Replies:** 1\
**Last updated:** [February 22, 2009, 11:58am UTC](https://www.ruby-forum.com/t/trailing-slashes-in-urls-causing-routing-errors-in-2-3-0-rc1/161014 "2009-02-22T11:58:38Z")

</div>

I just noticed that after updating an app to 2.3.0 RC1 (from 2.2.2) Rails now raises routing errors when it sees a trailing slash on the end of URLs for resources defined using the “:as” option. eg. given a resource l…

---

## [Literature 2 Music Rails Application](https://www.ruby-forum.com/t/literature-2-music-rails-application/161008)

<div class="topic-metadata">

**Author:** [@GabrielG1976](https://www.ruby-forum.com/u/GabrielG1976)\
**Replies:** 1\
**Last updated:** [February 22, 2009, 11:31am UTC](https://www.ruby-forum.com/t/literature-2-music-rails-application/161008 "2009-02-22T11:31:42Z")

</div>

Hello Everyone, I have finally deployed Literature 2 Music a rails music composing application. This application takes literature aka text and converts it into a music composition that can later be used to in any sof…

---

## [Parsing an xml file from another website](https://www.ruby-forum.com/t/parsing-an-xml-file-from-another-website/160981)

<div class="topic-metadata">

**Author:** [@skirkpatrick](https://www.ruby-forum.com/u/skirkpatrick)\
**Replies:** 3\
**Last updated:** [February 22, 2009, 5:33am UTC](https://www.ruby-forum.com/t/parsing-an-xml-file-from-another-website/160981 "2009-02-22T05:33:12Z")

</div>

I’m using getclicky for my site statistics. They have a url I can use to get the number of users online. I found ways to parse an xml file if it is local, but how should i do this if is from another link like http:/…

---

## [Joining three objects uniquely using :has\_many](https://www.ruby-forum.com/t/joining-three-objects-uniquely-using-has-many/161003)

<div class="topic-metadata">

**Author:** [@evan](https://www.ruby-forum.com/u/evan)\
**Replies:** 7\
**Last updated:** [February 22, 2009, 5:33am UTC](https://www.ruby-forum.com/t/joining-three-objects-uniquely-using-has-many/161003 "2009-02-22T05:33:11Z")

</div>

I’ve confused myself. I have three objects: level, product, part. Together they classify a repair type. Replacing a part in a product has a level of difficulty associated with it. The same part replaced in a differe…

---

## [From RPC to REST, quick design decision, need help](https://www.ruby-forum.com/t/from-rpc-to-rest-quick-design-decision-need-help/161006)

<div class="topic-metadata">

**Author:** [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Replies:** 1\
**Last updated:** [February 22, 2009, 4:38am UTC](https://www.ruby-forum.com/t/from-rpc-to-rest-quick-design-decision-need-help/161006 "2009-02-22T04:38:50Z")

</div>

Hello, Our app currently has an admin/logins/login\_by\_admin action. It basically allows the admin to login as a regular user of the system from the list of users in the backend. However, it clutters the logins contr…

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

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