similar to: Has_many :through problems -- please help

Displaying 20 results from an estimated 10000 matches similar to: "Has_many :through problems -- please help"

2006 Mar 22
2
habtm vs. has_many/belongs_to
In AWDWR David says (pg 232), "When a Join Wants to Be a Model: While a many-to-many relation with attributes can often seem like the obvious choice, it?s often a mirage for a missing domain model. When it is, it can be advantageous to convert this relationship into a real model and decorate it with a richer set of behavior. This lets you accompany the data with methods. As an example,
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 Mar 15
5
Passing params to a component
I see from http://rubyonrails.org/api/classes/ActionController/Components.html that is possible to pass paramaters to a component. I don''t understand the exact syntax. I''m trying: @master_id = @params[''master_id''] in the components controller but it is not working. ==== Details: In my calling view I have: <%= h(@opportunity.id) %> <div
2006 Mar 16
2
WEBrick and OS X 10.4.5 problems?
Has anyone who is running OS X 10.4.5 and the security patches thereafter noticed that WEBrick is no longer functioning? I have a machine at school that I believe to be patched with 10.4.5 but not with the latest security patch and WEBrick seems to run fine for it. However, on my machine at home I can''t get WEBrick to successfully run even freshly generated apps. For both
2006 Jun 19
3
Strange behavior of :through association.
class Host < ActiveRecord::Base belongs_to :person end class House < ActiveRecord::Base has_many :people, :dependent => true has_many :hosts, :through => :person end class Person < ActiveRecord::Base belongs_to :house has_many :hosts, :dependent => true end Now when I try to do: @hosts = House.find_by_id(params[:namas]).hosts from my controller I get this:
2006 Feb 03
6
Saving a User Object while in the Address Controller
Hi, My saves are failing me and I can''t figure out why. I am trying to save an address id to a user object just after I create the address. This isn''t the exact code, but it shows what I am trying to do. class AddressesController < ApplicationController def create @address = Address.new(params[:address]) saved_address = @address.save @user =
2006 Feb 23
11
Need help for simple RoR code.
I try a ''hello world'' demo here,It only show a ''hello word'' on web page you can see all my codes and structure here http://www.smtservers.com/demo/ I want to access the ruby app like this http://www.smtservers.com/demo/say/hello but I get a 404 error. Please let me know what problem the code have I am new for RoR. I am not sure the site structure is ok or
2006 Feb 13
11
ROR code syntax highlighting on blog?
I am interested in putting the cool syntax highlighting for ROR code. What''s the best way to do that? Is it using textilize or another formatting language? Or do I need special stylesheets? Any assistance is appreciated. Thanks Frank --------------------------------- Yahoo! Mail Use Photomail to share photos without annoying attachments. -------------- next part
2006 Jul 10
10
has_many :through and foreign key parameters
I just took my HABTM and turned it into a :through since my join table has another "non-joiny" attribute. I went from this: has_many_and_belongs_to :jobs, :join_table => ''tablename'', :foreign_key => ''x'', :association_foreign_key => ''y'' to this: has_many :jobs, :through =>
2006 Feb 28
5
Getting number of days in a month
In PHP, there was an argument you could pass to the Date function to get the number of days in the current month: echo date("t"); // Outputs "28" for February I don''t see anything like this in Ruby/Rails. Right now, I''m using a very ugly line to pull the last day of the month: @number_of_days = (Date.strptime(Date.today.strftime("%Y-%m-01"))
2006 Feb 03
2
Calling a javascript function after loading a partial with rjs
Hi, Is is possible to call a javascript function once a partial is loaded. Here''s what I am doing. I have a partial that gets updated via. an ajax call. When the partial is updated I want to call a javascript function ( enableTooltips ) which will then add tooltips to my links in the newly updated partial. Any help would be greatly appreciated. Thanks, Eric -- Eric Goodwin
2006 May 11
6
Dynamic data passing thru Rails to Flash
Hi, I am using Flash Dashboard and 3 sets of listbox. When i change my first list box say name i need to dynamically change the second list box and from the second list box when i choose an name i need to change the content according to this in the third list box. How can i pass this datas from database in rails. thanx g.balaji -- Posted via http://www.ruby-forum.com/.
2006 Jan 27
2
Trying to understand the difference between similar iterators
What''s the difference between these two? Objective: Trying to display the addresses of the students that has "has_many" relations with addresses <td><% @student.addresses.each {|address| "Address: #{address.addr1}<br/>"} %> </td> ****** did not work <% end %> This code worked: <td><% @student.addresses.each do |address|%>
2006 Apr 09
4
Inheritance via Though Associations?
I posted something about this a week ago wihtout response, but have made some progress since. However, I''m still not getting exactly what I want. OK, three core tables: create_table :reference_items do |t| t.column :title, :string, :limit => 255 t.column :year, :integer, :limit => 4 t.column :type, :string t.column
2006 Jan 27
5
Multiple Apps running under Lighttpd with scgi on a Windows Box ... possible?
I''ve run into a problem on one of my development machines. I''m trying to run multiple rails apps on one dev machine that runs Windows. Problem is that is seems that I can only run one scgi_service at a time, meaning that only one of my apps will function at a time. Anyone know how I can get around this, other than getting a *nix box (which I should have soon, hopefully) ?
2006 Aug 03
12
More than one has_many :through association between the same 2 models
I wonder if you can have more than one has_many :through association between 2 models. For example... I have a model Teacher and a model Class Now, 1 Teacher works in many Classes, right?. So I need a join model like class Work < ActiveRecord::Base belongs_to :teacher belongs_to :class end But I also would like to know if a teacher CAN teach a class before I
2006 Mar 01
1
Net/Https & active_rbac & Debian Sarge
Hi, I''m attempting an install of active_rbac but am having some troubles. I''m running Debian 3.1 sarge and I am getting an error saying that I need to have net/https installed. I checked out my ruby lib and net/https.rb is nowhere to be found. I''m running the default ruby for Sarge which is 1.8.2. Was https.rb not included in this build? How can I get around this? I
2006 Feb 10
4
How to do a find with conditions that contain an OR
Hi, I''m trying to do a find with a condition that has an OR on the same column. Say I only want to use find() but not find_by_sql(). I reduced my problems into the following: values = [] ... # filling up values from params Order.find(:all, :conditions => ["(action = ? OR action = ?) AND price = ?", values] For example I
2006 Mar 25
11
Firefox ''Rails Mailing List'' search engine plugin
Hi all, If you''re like me you probably spend a lot of time search the Rails mailing list. To make life a little bit easier I''ve created a nice little plugin for firefox ( A whopping 15 lines of markup ). The plugin uses nabble.com to search the mailing list. Anyways, I thought I''d share. If you want to install it the manual way, here''s the code. <search
2006 May 12
4
POST vs GET
I read in the Agile Rails book that I should avoid GETs for destructive actions. I notice that on 37signals'' Backpack web site, deleting an item in a list is accomplished with a simple click on a picture of a trash can. Is this a violation of the POST/GET rule noted above, or is there some way to make a clickable link send a POST? Ben