I've just installed AS into an existing app, and managed to get a
basic listing going very quickly.
I'm having trouble configuring associations, though. been searching
docs, tutes and the google group for a couple of hours now, and
haven't been able to figure them out.
Here's what I have, stripped to essentials for this post:
trying to do 2 things:
one is to get a column for Physique on the People listing, with a link
that will show Physique's content. with the current config, it ends up
showing fields for Person, not Physique.
the second is to show Physique's fields when showing a Person. right
now the physique title appears, so the column is recognized, but it
doesn't fetch any data.
any pointers would be greatly appreciated - it'd be great if there
were more concrete examples regarding dealing with associations in AS,
from what I could see a lot of newcomers get stuck with them in the
beginning...
- Oliver
1. If you remove set_link line you will get a link to edit the associated
record. If you want to get a show link remove edit from
actions_for_association_links (look at API: Column)
config.columns[:user].actions_for_association_links = [:show]
2. If Physique hasn't name, label or title method, you should define a to_label
method.
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) ser...@entrecables.com
thanks for your response.
1) when I remove set_link I get a routing error:
and leaving :show as the only action in actions_for_association_links
gives me a similar error, this time for the :show action:
No route matches {:action=>"show", :parent_controller=>"admin/people",
:controller=>"admin/physiques", :_method=>:get, :id=>1}
2) it's already defined, that's what's confusing:
class Physique < ActiveRecord::Base
belongs_to :person
def to_label
"#{ethnic_group}, #{height} cm, Olhos #{eyes}, Manequim: #{clothing_size}"
end
end
the weird thing is that the :physique column, with set_link declared,
shows Person with the associated Physique data correctly
so it's a mess:
on the People listing the :physique column shows the person's data
with included physique data, but the default :show action link doesn't
> 1. If you remove set_link line you will get a link to edit the associated
> record. If you want to get a show link remove edit from
> actions_for_association_links (look at API: Column)
> config.columns[:user].actions_for_association_links = [:show]
>
> 2. If Physique hasn't name, label or title method, you should define a to_label
> method.
>
> --
> Sergio Cambra .:: entreCables S.L. ::.
> Mariana Pineda 23, 50.018 Zaragoza
> T) 902 021 404 F) 976 52 98 07 E) ser...@entrecables.com
>
> --
>
> 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 actives...@googlegroups.com.
> To unsubscribe from this group, send email to activescaffol...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
>
>
>
--
Oliver Azevedo Barnes
----------------------------------------
Web Application Developer
+55 11 8147 5272
http://www.linkedin.com/in/oliverbarnes
config.columns[:physique].actions_for_association_links = []
I managed to at least get the physique label to show. I can live with
that for now...
but when showing the person's details after clicking on 'show' on the
people listing, I'd like the physique column to show all the
configured physique columns, instead of the label. is there a way to
do that?
another question - when editing a person from the listing, how can I
override the nested physique form as to have it show vertically
instead of horizontally?
2009/12/30 Oliver Barnes <oli.azeve...@gmail.com>:
How have you defined your routes?
You have to do a show override:
http://wiki.github.com/activescaffold/active_scaffold/show-overrides
>
> another question - when editing a person from the listing, how can I
> override the nested physique form as to have it show vertically
> instead of horizontally?
Set in PhysiquesController the layout for subform:
active_scaffold do |config|
...
config.subform.layout = :vertical
...
end