Hi Jeurgen,

If you see my recent post i have the same issue
http://groups.google.co.uk/group/activescaffold/browse_thread/thread/84452e8c72c176da

Basically using AS with has many :through you cannot crete or edit
associations, AS does support HABTM but its not possible for me or you
by the sounds of
it to change all those relationships just to suit AS.  My issue is the
same apart from i can see all the possible assocation options in the
check box list but if i edit any it just doesnt save.  I did change
mine around like yours so i was then getting only the selected options
in the checkbox list but not the entire model.  You should be able to
get this by changing :categorizations to :categories in your blog
controller but as i stated then the edit wont sane any updates.  Will
see if any of the community come with something to help.

For your 2nd point you have a couple of options.  Probably the easiest
is to exclude the exisiting show link like so and then add a new one
to your config.columns.
So in you blogs controller add :new_show to your exisiting columns
config.columns =
[:title, :body, :is_posted, :categorizations, :new_show ]

and in you blogs helper add something like the below to make the
new_show field an active link
config.columns :new_show

def new_show_column(record)
     link_to "Show", :controller => 'blogs', :action => 'show', :id =>
record)
 end

The other option is to overrite the partial that displays the action
links which may take a bit more time digging arouns.

JB

On 23 May, 14:05, helmerj <[email protected]> wrote:
> Hi!
>
> I have trying to switch an existing application over to
> active_scaffold. I use several "has_many through" relationships in a
> number of models to let the user specify a set of features for each
> model.
>
> I have created a simple test application using rails 2.3 and
> active_scaffolds master branch. Following the README I have also
> installed the render_component plugin.
>
> I have two models, blog and category and the categorization model
> connecting them as follows:
>
> class Category < ActiveRecord::Base
>   has_many :categorizations
>   has_many :blogs, :through => :categorizations, :source => :blog
> end
>
> class Blog < ActiveRecord::Base
>   has_many :categorizations
>   has_many :categories, :through => :categorizations, :source
> => :category
>   validates_presence_of :title, :body
> end
>
> class Categorization < ActiveRecord::Base
>   belongs_to :blog
>   belongs_to :category
>
> #set the name of categorizations column in blog listing to categories
> names
>    def to_label
>     "#{category.name}"
>   end
> end
>
> After a long struggle I have figured out how to actually have anything
> displayed at all:
>
> In my blogs controller I have this:
>
> class BlogsController < ApplicationController
>  active_scaffold :blog do |config|
>     config.columns = [:title, :body, :is_posted, :categorizations ]
>
>     config.columns[:categorizations].form_ui = :select
>     config.columns[:categorizations].label = "Categories"
>
>     config.columns[:is_posted].label = "Entry posted?"
>     config.columns[:is_posted].form_ui = :checkbox
>   end
> end
>
> This will display all categories with the correct name from the
> category table as assigned in the categorizations table.
>
> GREAT!
>
> BUT:
>
> 1. When I click on the edit button for any record I do not see all
> categories available in the categories table but only any category
> that is currently assign or has been assigned before, since the
> unchecking of a category only removes the blog_id entry from the
> categorizations table but not the entry itself.
>
> Question: How can I have all available categories listed in the edit
> view?
>
> 2. The category entries are linked (http://localhost:3000/blogs/1/
> nested?_method=get&associations=categorizations) How would I change
> the link to the show page of the associated category?
>
> I am sorry if this is trivial. I have tried to find a howto or any
> other documentation on the matter but was not able to find anything
> helpful.
>
> Thanks in advance for any help
>
> Cheers Juergen
--~--~---------~--~----~------------~-------~--~----~
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