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 3271976
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:46:49+00:00 2026-05-17T18:46:49+00:00

This design question needs a bit of context, so please bear with me. I

  • 0

This design question needs a bit of context, so please bear with me.

I currently have three models that go something like this:

class MyItem < ActiveRecordBase
    has_many :my_list_items
    ...

class MyList < ActiveRecordBase
    has_many :my_list_items
    has_many :my_items, :through => :my_list_items
    ...

 class MyListItem < ActiveRecordBase
     belongs_to :my_item
     belongs_to :my_list
     has_many :my_list_item_properties

 class MyListItemProperty < ActiveRecordBase
     belongs_to :my_list_item

As you can see, the MyListItem model is more than a simple join table, it has other properties as well.

There are two main views in the application. One displays all MyItems regardless of which MyList it belongs to, and provides standard CRUD operations for these. The other view displays a MyList, with data from all its MyListItems and the associated MyItem of each. This view allows inline editing to existing MyItem objects (that are associated with the list via MyListItem), and inline forms to create new MyItem objects and associated MyListItem. These inline actions rely largely on partials and RJS.

Now I have two options:

  • I can have controller methods to facilitate e.g., the creation of a new MyItem in both MyItemController and MyListController, where each is responsible for its associated views. This is a slight violation of the DRY principle, but it simplifies rendering/redirect logic and the association of partials/RJS with controller actions.

  • Or I can make the forms and AJAX links from MyList views submit to MyItemController, which then has to take care to render partials or RJS from MyList when appropriate. This also seems to require me to specify a :controller => my_list for each link_to_remote in MyList related views. This seems to be a more RESTful approach and limits the creation of MyItem objects to one controller, but it complicates the controller logic somewhat.

Which method do you prefer and why?

  • 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-17T18:46:49+00:00Added an answer on May 17, 2026 at 6:46 pm

    I often have this debate with myself also and I think I usually favor option #1. As a best practice we’re usually striving for skinny controllers and looking for ways of factoring initialization/creation logic into the Model. In a perfect world, most of the logic in the action would be the view specific rendering/redirect logic that you’d be branching on for option #2.

    I also feel the requirements tend to diverge over time for different views: “We’d like to show a different flash message on this page”. Which would be just more branching for option #2.

    After factoring any initialization logic that’s reasonable to the model and maybe using a common before_filter in the controllers, option #1 would likely feel pretty clean & DRY.

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

Sidebar

Related Questions

This is a design question, I noticed that by time by LINQ-to-SQL Context gets
Java design question. I have an object that needs to maintain sets of say
This is more of a design question. I have a template class, and I
This is more of a general design question I guess... I have an Ajax
This is probably more a design or style question: I have just been considering
This looks like a long question because of all the context. There are 2
This is a tough design question for a application I'm working on. I have
This is a bit of a generic question about java class design and how
This is a design question: when do I need to create/use a static method
This is a design question. I'm trying to decide between 2 implementations. In order

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.