Forum: Ruby on Rails Joins, paginate and casting an integer to a string

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B658b647e472925b1441ac17c7652415?d=identicon&s=25 Jez (Guest)
on 2007-01-19 16:29
(Received via mailing list)

I need some help please.

I have two tables:



An account can only have one accountdescription but a description can
have many accounts.

I have created two models: account & accdesc

for account I have:
has_one :accdesc

and for accdesc:
belongs_to :accounts

Is this correct? It might be causing the other problem I have ...

I want to use paginate to create a list of accounts with their type i.e
do a join between the two. I thought rails did this stuff for me but I
can't get it to work.

 @account_pages, @accounts = paginate :accounts, :per_page => 10

How do I get to the accountdescription please?

Also how do I cast an integer into a string? I have some very complex
SQL I  need to run out of find_by_sql and the id is held in

I  have googled for all the answers but I haven't found anything.

72f8ab180f81f9c544e2b58da399c0be?d=identicon&s=25 Elad Meidar (eizesus)
on 2007-01-19 16:31
(Received via mailing list)
Hi Jez,

:account belongs_to :decription
:description has_many :accounts

and of course Account table must include a foreign key to the
description table (Default being used is accdesc_id)

integer casting:

you have 3 options:
1. use interpolated string => "Elad is #{@programmer.age.to_s} years
2. concat strings => "Elad is " + @programmer.age.to_s + " years old"
3. when setting a condition in sql query => SuperHero.find(:first,
:conditions => ["power_count = ?", @power_count_needed].

any questions, i'm on

hope this helps.
This topic is locked and can not be replied to.