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