Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:07:10+00:00 2026-05-27T05:07:10+00:00

I have this code: class ArticlesController < ApplicationController active_scaffold :articles do |config| config.label =

  • 0

I have this code:

class ArticlesController < ApplicationController
  active_scaffold :articles do |config|
   config.label = "Manage my articles"
   config.actions.exclude :show

    form_cols = [:name, :summary, :content, :author, :category, :article_date]

      config.columns = form_cols

      config.list.sorting = {:content_file_name => :asc}
      config.columns[:category].css_class = 'categories'
      config.columns[:category].clear_link
      config.columns[:category].form_ui = :select
......

and models

class Article < ActiveRecord::Base
  belongs_to :category, :class_name => 'Category'
end

class Category < ActiveRecord::Base
  has_many :articles, :foreign_key => :category_id
end

Category is mapped on this table

CREATE TABLE `categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `active` tinyint(1) DEFAULT '1',
  `group` varchar(255) DEFAULT 'novel',
  PRIMARY KEY (`id`)
);

i want to show only categories with a particular “group” depending on the user_type.
The problem is that i don’t know how to filter the rows in a relation.
I can see that activescaffold perform two queries, one for the articles and a second for the Category ( SELECT * FROM categories) so a want to change this second query (like SELECT * FROM categories where group=’something’.
do you have any suggestion?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:07:10+00:00Added an answer on May 27, 2026 at 5:07 am

    If I understand the question, you need to filter the categories available in select menu for new and edit article, basing on a parameter.
    If this is the case, you can override options_for_association_conditions(association) in articles_helper, for example:

    module ArticlesHelper
      def options_for_association_conditions(association)
        if association.name == :category
          ['categories.id IN (?)', current_user.available_groups.map(&:id)]
        else
          super
        end
      end
    end
    

    see: https://github.com/activescaffold/active_scaffold/wiki/Custom-Association-Options

    Another option could be customize how the select is rendered adding a _category_form_column partial in views/articles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: class MyObj { int Id; string Name; string Location; }
I have this code: public class Window extends JFrame { public Window(){ ... JButton
I have this code inside a class that is used by an application and
I have this code in base class protected virtual bool HasAnyStuff<TObject>(TObject obj) where TObject:class
Okay, so i have this code i wrote: class Connection { public static StreamWriter
I have this code which compiles and works as expected: class Right {}; class
So I have this code inside my lib/ folder: class GlobalConfig::SetHelper def self.yes_no_input(configuration) value
So I have this code for these Constructors of the Weapon class: Weapon(const WeaponsDB
Lets say I have this code: <?php class hello { var $greeting = hello;
I have a curl class, called Curl. Let's presume i have this code: $url

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.