Well...  I need an actual model since I have validations for my join
table.  This requires has_many :through instead of habtm.  AS sees the
has_many :through and gets helpful, but in the wrong ways.


On Nov 12, 12:11 pm, Vince <[EMAIL PROTECTED]> wrote:
> I see you have created a controller for your join table which seems
> it's ArticleTags and have a scaffold on it.  I am wondering
> if this is the ideal way to work through the association or if there
> is a better way.  For example if you wanted all articles with a tag
> that has a name of "test", then
> this would come from the ArticleTagsController?  I could be completely
> off in my understanding of all this.  I am new to rails and active
> scaffold.  I am wondering
> if creating a controller for a join table is ok and creating a
> scaffold for this controller.
>
> On Nov 11, 5:03 pm, Student <[EMAIL PROTECTED]> wrote:
>
> > Articles can be tagged.  The tags table contains a name and value.
> > Each article can only have one tag with a given name.  In the article
> > update page, I want to be able to select a name for a tag from a
> > dropdown, then a value for the tag from a dependent dropdown.  (For
> > example, the "importance" tag might have values "who cares?", "walk
> > away", and "run for the hills!".  The "credibility" tag might have
> > values "tin foil", "omg", "TRVTH".)
>
> > What I'm getting is two empty dropdowns.  I have defined name_column
> > and value_column in ArticleTagsHelper, but they are not being called.
>
> > Help?
>
> > class Article < AR::B
> > ...
> >   has_many :article_tags
> > ...
> > end
>
> > class ArticleController < AC
> > ...
> >   config.columns = [ ... :article_tags]
> > ...
> > end
>
> > class Tag < AR:B
> >   validates_presence_of :name
> >   validates_presence_of :value
> >   validates_uniqueness_of :value, :scope => :name
> >   has_many :tag_values, :dependent => :destroy
> > end
>
> > class ArticleTag < AR::B
> > ...
> >   validates_presence_of :article_id
> >   validates_presence_of :tag_id
> >   belongs_to                 :article
> >   belongs_to                 :tag
> >   validates_uniqueness_of :article_id, :scope => name
> >   def name
> >     tag ? tag.name : nil
> >   end
> >   def value
> >     tag ? tag.value : nil
> >   end
> > end
>
> > class ArticleTagsController < AC
> > ...
> >     config.columns = [:article, :name, :value]
> >     config.subform.columns.exclude :article
> >     config.columns[:name].form_ui = :select
> >     config.columns[:name].required = true
> >     config.columns[:value].form_ui = :select
> >     config.columns[:name].required = true
> > ...
> >   end
>
> > Pointers?
--~--~---------~--~----~------------~-------~--~----~
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