similar to: Bad design or better way?

Displaying 20 results from an estimated 10000 matches similar to: "Bad design or better way?"

2006 Jul 02
5
Question about setting field values for a belongs_to model
I have two tables, applicants, and skills where each applicant "has_many" skills, and each skill "belongs_to" an applicant. When I have a reference to an applicant and a (skill) id for one of their skills, I thought to update their skills by using @applicant.skills.find(id_of_skill).description = ''new description'' # even adding
2006 Jul 15
3
How bad is it to have 7 joins in my find_by_sql?
My question is whether there''s a more idiomatic rails way of structuring this query or of redoing the underlying models. First, the ugly find_by_sql code, which is the method to generate an atom feed: def atom items_per_feed = 15 sql_query = "SELECT activities.*, users.real_name AS real_name, accounts.last_scraped_at AS last_scraped_at,
2007 Apr 29
1
better nested set and :through
Hello all, It''s been a while since i''ve been doing any rails development, so i''m a bit rusty. Having found this: http://opensource.symetrie.com/api/better_nested_set/ it looks really interesting and useful for solving something i''m trying to get working. What i have (essentially) is the following models: class Group < ActiveRecord::Base
2005 Sep 23
6
problem with acts_as_tree
Hi, I''m using the latest gem version of rails under MacOS Tiger. I was trying to use acts_as_tree as described in the rails book. So I have something like: class Category < ActiveRecord::Base acts_as_tree :order => "title" end create table categories ( id int not null auto_increment, title
2006 Nov 22
3
RESTful web service design question
I''m working on a Rails app that needs to expose a RESTful web service. I''m curious to know some of the best practices as it relates to RESTful API design. Let''s say I have a set of related objects on the server side. I''ll use the venerable subscribers, subscriptions and magazines example to lay it out. class Subscriber < AR has_many :subscriptions
2006 Jan 12
2
Can A Model Have Many belongs_to?
I am very new to Rails. After skimming through the documentation over the last several days, I''m struggling with the appropriate use of belongs_to. My main question is whether a model can have several belongs_to declarations. I have not seen any examples online show that usage. If it can, then I would like to know if it''s poor form or what the best practices are around
2013 Feb 10
0
Nested attributes doesnt get updated
Hi Am building a nested form and my code works fine with sqlite3 but throws errors when using Oracle during update action. Am getting the following error: ActiveRecord::RecordNotFound in AWRequestsController#update Couldn''t find WADetail with ID=5000000015 for AWRequest with ID=5000000022.0 Request *Parameters*: {"utf8"=>"✓",
2007 Sep 18
2
Making attachment_fu polymorphic
I am working on a small model mixin called attachment_kung to make attachment_fu polymorphic, so you no longer need a different table and Model class for every associated attachment (Productimage, Ad_doc, etc). All you really need is one model and table to handel all your attachments - in some cases, anyway. I have the code working, but have run into one small hitch that I can''t seem to
2008 Apr 23
1
Validation dependent on unsaved parent
I''m having trouble with a validation that depends on an attribute of a belongs_to parent. If the child is added to an unsaved parent (parent.children << new child), the has_many collection parent.children includes the unsaved child. However the belongs_to attribute child.parent appears to be nil until the parent has been saved. Without access to the parent attributes, the validation
2010 Jan 27
2
has_many, through with nested models?
First the data model: class Forum < ActiveRecord::Base has_many :topics, :dependent => :destroy, :order => ''created_at desc'' end class User < ActiveRecord::Base has_many :topics, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :replies, :dependent => :destroy end class Topic < ActiveRecord::Base belongs_to
2007 Mar 31
3
Sorting issues, can anyone help me?
I have this model: class Post < ActiveRecord::Base acts_as_ferret :fields => { :title => {:boost => 2}, :description => {}, :url => {}, :rank_sort => {:index => :untokenized_omit_norms, :term_vector => :no},
2009 May 15
0
[PATCH server] use service layer for Network controller.
There's still room for additional refactoring as we may want to eventually split out nic, bonding, and ip address manipulation into their own controller/svc module, but that would be a much more extensive redesign than we want to deal with for the overall service layer creation refactoring. Signed-off-by: Scott Seago <sseago at redhat.com> --- src/app/controllers/network_controller.rb
2006 May 12
1
can I fake has_one :through?
I''m having a difficult time wrapping my head around a set of models and their associations and seeing how they map into Rails. I''ll try to lay out my problem using the has_many and belongs_to structures. I have a RuleSpace, a Rule, and a Subject. A RuleSpace has_many Rules A RulesSpace has_many Subjects through Rules A Rule belongs_to (many) RuleSpaces A Rule has_many
2010 Jan 25
0
has_many, :finder_sql, setting attributes
Hi all, My question is somewhat complicated, but bear with me. My project has a number of models: User, Program, and Team. Users belong to multiple Programs. Programs have multiple teams, but Teams belong to one program. For each Program a User belongs to, he can belong to multiple Teams. (Think of this in an athletic context where users are athletes, programs are universities). So my
2006 May 18
3
Model Madness: habtm vs through
This has me scratching my head: a Person has many Things a Person has many Collections a Collection has many Things ...Things in a Collection are ordered ...Things in a Collection can be related to (created by) any User ...a collection has additional attributes, such as a name etc I am confused about habtm in rails (especially when using acts_as_habtm_list) vs. going the :through route.
2013 May 13
1
RAILS GET IDS
I don''t know how to solve something about a project I''m doing in Ruby on Rails. I want to save the IDS of my 3 models to my table DETAILS between these, my BD is Mysql. ASIGNATURAS--MALLAS--NIVELS-------->ASIGNATURA_ID--_MALLAS_ID--_NIVELS_ID In the view MALLA, i list my asignaturas, mallas and niveles, and in the controller MALLA i want to save the arrays to my model
2006 Oct 30
2
It this possible: finder_sql-like behavior for belongs_to?
Guys, I have a need to support as has_many/belongs_to relationship on a legacy(kind of) schema. The reason I say kind of is that the schema does have "id" columns that are used in many associations, but this particular has_many/belongs_to association needs to support different ones. I''ve attached to code at the end of this email. Suffice it to say I need to use the standard
2006 Apr 03
0
has_many questions
My application has two models I''d like to have multiple join tables between, Users and Groups. Users have the ability to subscribe to a Group, while a Group would like to know its membership. Additionally, a User can administer several Groups and a Group should know about its several Administators (Users). I have the following declarations: class Administrator <
2006 Aug 16
0
Polymorphic Associations and grouping users and projects
Hi all, In my app I would like to create user groups in my admin. Currently I have the following models and associations that facilitate this. class User < ActiveRecord::Base has_many :memberships has_many :groups, :through => :memberships end class Membership < ActiveRecord::Base belongs_to :group belongs_to :user end class Group < ActiveRecord::Base has_many
2006 Apr 21
3
polymorphic,has_many through can not work?
Josh Susser tells in his blog that the opposite direction of polymorphic will get into trouble together with has_many through. This is the url: http://blog.hasmanythrough.com/articles/2006/04/03/polymorphic-through I do that according to Josh Susser''s procedure: class Tagging < ActiveRecord::Base belongs_to :tag belongs_to :taggable, :polymorphic => true belongs_to