You should have a "to_label" method in your model to let AS know how
to show it (simple to_s can be used instead but I would prefare
to_label asi it is AS related approach). So write  something like:

class People

 # ...

  def to_label
     "#{firstname} #{surname}"
  end

end

On Oct 5, 8:43 pm, Jan <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I found the problem. I insterted a column "place_id" into peoples
> table and it works!.
>
> But another problem has risen: i am getting instead of people
> something like this: "#<People:0x68d673c>".
>
> Thanks
>
> J
>
> On 5. Okt, 10:21 h., Jan <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I became a user of AS few days ago. Despite reading Documentation and
> > this forum, I was not able to find how to create relationship between
> > 2 models.
>
> > I have 2 models: place and people. 2 controllers - places and peoples
>
> > Models:
> > ###
> > class Place < ActiveRecord::Base
> >   has_many :peoples
> > end
>
> > class People < ActiveRecord::Base
> >  belongs_to :place
> > end
> > ###
> > Controllers:
> > ###
> > class PlacesController < ApplicationController
> >   layout "places"
> >   active_scaffold :place do |config|
>
> >     config.nested.add_link "People", [:peoples]
> >   end
> > end
>
> > class PeoplesController < ApplicationController
> >   layout "peoples"
> >   active_scaffold :people do |config|
> >     config.label = "People"
> >     config.columns =
> > [:last_name, :first_name,  :family_name, :date1, :date2, :place_number]
> >     list.columns.exclude :poznamka
> >     list.sorting = {:priezvisko => "ASC"}
> >     columns[:place_number].label = "Place"
> >    end
> > end
> > ###
>
> > Using AS only, everything is working fine. Once I add a relationship,
> > (has_many, belongs_to + config.nested.add_link), I am getting error:
>
> > Mysql::Error: #42S22Unknown column 'peoples.place_id' in 'on clause':
> > SELECT count(DISTINCT `places`.id) AS count_all FROM `places`  LEFT
> > OUTER JOIN `peoples` ON peoples.place_id = places.id
>
> > I assume I need to set somewhere what columns should be used for
> > association. In my case, both tables contains column
> > 'place_number' (something like place_id) -  and this column should be
> > one used for association.
>
> > There is no foreing key present at the moment in mysql database. This
> > might be the cause?
>
> > I would highly appreciate your advice if you spot what is missing. My
> > assumptions were, that somewhere need to be set a foreign key.
>
> > Thanks
> > J
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to