similar to: ActiveRecord Many-To-Many relationship question

Displaying 20 results from an estimated 1000 matches similar to: "ActiveRecord Many-To-Many relationship question"

2006 Feb 13
5
Acts_as_taggable pluralize
I am implementing a messaging system, which requires broadcast to group feature. Instead of a relatively clunky habtm group structure, I am using tags. Form a usability standpoint, it would be helpful to avoid redundant tags. Like, friend vs friends OR client vs. clients. Is it practical to filter tags, before entry, to avoid duplicate tags like plural vs. singular? -- Posted via
2006 Jan 15
1
Attributes of a relationship
Hi all, I have two types of models which I''m not sure how to model (or if it''s even feasible) with ActiveRecord. Let me know if you''ve got any good ideas. 1) For those of you who are familliar with del.icio.us, you probably know that you can bookmark a site, and add your own tags to it. Each person has their own tags for a site, even though multiple people can
2009 Oct 08
6
Eager Loading a Relationship That Has No PK/FK
I''m attempting to wrestle an old DB into Rails. This relationship is giving me trouble: class Show < AR::Base has_many :segments end class Segment < AR::Base belongs_to :show has_one :media #this has no PK/FK relation end A Segment is "linked" to Media by Media.name, which is the result of concatenating Segment.name and Segment.part. As I said there are is no
2005 Oct 11
4
Searching an attribute in a hmabtm relationship
(Nuby to Ruby and Rails...) I''ve implemented security using the login generator in a simple app so that I have a user table, a roles table, and a join between them (roles_users). All works as expected. I now need to check if a user has a specific role, but my approach is off somehow. Here''s what I''ve tried thusfar: user_roles = @session[:user].roles
2006 Mar 05
8
Model Inheritance, Mixins and Database design
I''m trying to understand how best to use inheritance and wonder if Rail''s Single Table Inheritance model too restricting. I have a model Companies who provide 1+ Services (HABTM relationship). I assume the best way to represent this is with a series of child models representing each type of service : ServiceType < Company. I want to return lists of companys for each
2006 May 08
2
Queries with has_and_belongs_to_many relationship
I was able to create a has_and_belongs_to_many relationship for my app, but now I''m not too sure how to write queries for it. Basically, I have a table ''courses'' that has_and_belongs_to_many ''categories'' and vice versa So I''m trying to figure out how I would find only the courses that belong to a category that I specify. Let''s
2006 Feb 12
4
How do I emulate directory structure with routes?
I''ve got something that I''m not sure is actually doable. I have a very complex model relationship with a lot of parent/child/grandchild/ greatgrandchild etc stuff going on. Is there a way to do a route like this? tld.com/ projects/:project_name/:sequence_acronym/:shot_number/:department/:eleme nt_name/:version/ where: project is the parent of sequence sequence is the
2006 Mar 31
5
Changing Table Schema and Models
If I make a change to a database table, how do I recreate the model to reflect the change? -- Posted via http://www.ruby-forum.com/.
2006 Apr 07
6
Magic Field Names - "position"
What does the Magic Field Name position do? I was looking here: http://wiki.rubyonrails.com/rails/pages/MagicFieldNames And unfortunately that documentation is incomplete. Thanks. -- Posted via http://www.ruby-forum.com/.
2006 Mar 25
3
Rails Plugins: Why to register your own functionality with send()?
Hi there, I have seen in the file column plugin ( http://www.kanthak.net/opensource/file_column/) from Sebastian Kanthak or David''s acts_as_taggable plugin that to register my functionality I need to do something like this: ApplicationHelper.send(:include, InPlaceEditAssociations) I am wondering why not: (a) module ApplicationHelper include InPlaceEditAssociatons end or: (b)
2006 Mar 25
4
dynamic set_table_name for achives
How can I pass something to set_table_name so that I can switch tables on the fly for accessing archive data? If I could access sessions inside a model I would do something like: if @session[:current_period] set_table_name "statistics_" + @session[:archive_year] else set_table_name "statistics_" + Date.now.year end But since I cannot access the session from within a
2005 Dec 23
3
Intergrating delicious?
Whats the best way of intergrating del.icio.us into a RoR app? -- Posted via http://www.ruby-forum.com/.
2006 Jan 07
2
Before filter...
I have a before filter in my application.rb, for every action and controller it gets run, except for one action. How can I see whats going on? And why it doesnt get run? Thanks joey__ -- Posted via http://www.ruby-forum.com/.
2010 Sep 12
11
Rails 3: finding a record by name in multilingual app
Hello, I upgraded my application from Rails 2 to Rails 3 and ran into a problem. In rails 2 I could use the english name of the record to find it like: Page.find_by_name("Welcome") even though the user chose German as the language (which of course showed the German welcome page. Eversince I switched to Rails 3 (default_locale still :en) I can''t find anything by giving the
2006 Feb 21
4
Models, Helpers, Modules, etc.
Hello, I am learning rails and ruby and I have some questions about how should I go about doing certain things. [1]Many of my models have some functionality which is common, and instead of duplicating it across models, I want to store it in a single file, and then import the file into the models. Should I do this using modules, and then store them in the `lib'' directory? What is the
2006 Feb 26
3
Rails Naming Conventions
DB field names: If I have a table that references 2 or more separate users from my users table, is there a recommended naming convention for this situation? In my case, I have 3 users associated with a record in my projects table: requester_user_id created_by updated_by I could name one of them "user_id", and then projects.user would work I guess, but wouldn''t work
2006 Jul 02
5
Pretty URLs -> Routes
Hi I am having issues with getting my pretty urls to work. routes.rb: map.connect '':user'' , :controller => ''front'' , :action => ''list'' , :filter => ''user'' front_controller.rb: def list @advert_pages, @adverts = paginate :adverts, :per_page => 10 @user =
2008 Jul 08
3
undefined method `name' ...........
Hi Community.... I''m new in this game, so this might be a easy question, but I have done my google, without result, so I will try this.... I''m learning ROR, and I''m using Patrick Lens ''Ruby on Rails'' book. (This is written for ror 1.x - and I''m using NetBeans 6.1 - ror 2.x - this might be the problem...) But... I have made this
2006 Jul 17
10
getting the user name
Hi I am new to ruby and trying to obtain the user name in the login index.rhtml where I could display "You have logged in [user name]" How could I do this? I have been trying different options after reading the ruby manual but still throw an error. please help -- Posted via http://www.ruby-forum.com/.
2006 Nov 14
3
messed-up habtm relationship
Hi, I have a many-to-many relationship between dishes and ingredients class Dish < ActiveRecord::Base has_and_belongs_to_many :ingredients end class Ingredient < ActiveRecord::Base has_and_belongs_to_many :dishes end I have a join table dishes_ingredients now when i access my_dish.ingredients, i get a list of what looks like Ingredient objects, but the but they don''t have