similar to: Creating objects with has_many :through relationship

Displaying 20 results from an estimated 1000 matches similar to: "Creating objects with has_many :through relationship"

2006 Feb 23
3
has_many reference
I am trying to do something right from Agile Web Dev with Rails book and it does not work. I must be missing something obvious. I have a one-to-many relationship: class Draft < ActiveRecord::Base has_many :endorsees end class Endorsees < ActiveRecord:: Base belongs_to :draft end >From my reading, methinks I should be able to say: d = Draft.new d.endorsees << Endorsee.new
2005 Dec 29
3
Post problem with select lists
hey, i have this problem how come i always get -1 for the select list?? rhtml First, select a client. <select id="client_id" name="client[id]" onChange="submit();" > <%= options_for_select(@client_options, @client_id.to_i) %> </select><%= @client_id %> controller if @request.post? if @request.xml_http_request? #called by ajax,
2006 Feb 08
2
compound conditions in find
can''t seem to find the right syntax for this... /script/../config/../app/controllers/placements_controller.rb:155: syntax error :conditions => [["placements.client_id = ?", params[:client_id] ] and "placements.discharge_date IS NOT NULL" ], this part works... :conditions => ["placements.client_id = ?", params[:client_id] ] this is what I
2006 Jul 08
4
Hidden fields in forms
Please can someone show me the correct syntax for a hidden field in forms, this is my code <%= start_form_tag :action => ''create'' %> <div class="form1"> <table width="auto" boader="8" cellspacing="5" cellpadding="5"> <% hidden_field ''line_item'', ''client_id'', :value
2006 Mar 07
6
how to add onchange javascript event to select field
I would like to add javascript ''onChange'' event handling for a select field, such as <%= collection_select("job", "client_id" , @clients, "id", "name") %> with onChange="xxx" Anyone know how to make this work? Thank you, Scott -- Posted via http://www.ruby-forum.com/.
2007 Dec 22
3
collection_select validation problem
I''m trying to assign a parent foreign key value using collection_select from my child "new" form. The problem I''m having is if I do not make a selection, I get the following error instead of the Rails validates_presence_of error: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating
2006 Jun 13
13
Pass infomation between different views and controllers
Hi, I am a rails and ruby nuby :-) How do you pass data between different controllers and views? I have a page ( a quote) that I am editing url ....quote/edit/6 6 id the current id. I then go to a catalog (url....catalog) to add an item to my quote (I do this via a line_item file that the quote reads) I now want to go back to the quote. I have tried this <%= link_to ''Back to
2007 Oct 25
1
find - group - postgres
I am not sure that this is entirely a rails question as I am trying to run the command in postgres and I am getting the same error... controller code... @client_slot_count = ClientSlotsDaily.find(:all, :conditions => ["created_at > ? AND created_at < ? AND facility_id = ? AND client_id IS NOT NULL", starting_date, ending_date, @facility.id],
2010 Dec 29
1
filling up holes
I have a data frame with three columns client ID | date | value For each cilent ID I want to determine Min date and Max date and for any dates in between that are missing I want to insert a row Client ID | date| NA Any help would be appreciated.
2006 Apr 13
1
Adding a title to an AJAX link.
Hello all. I am trying to add a title to a link_to_remote created AJAX link. What I want to create is: <a href="#" title="VALUE-HERE" onclick="new Ajax.Updater(''content'', ''/area/show/28/40'', {asynchronous:true, evalScripts:true}); return false;">Area Name</a> However I cannot seem to get it to work, the API says
2006 Feb 11
6
Rails Edge, has_many :through in searches
I have two tables, a Projects table and a Clients table. It''s basically a HABTM relationship, but I have additional project/ client-specific information in the join table. I''m trying to use the new has_many :through method to join these. It works fine when displaying records, but when I try to search, I''m having this problem: When I used a HABTM model to search
2011 Feb 22
1
collapsing by a key in a compound database
Hello all. I have a problem with collapsing by a key in a compound database. I have 2 databases (e.g. clients and client branches), both of them have the same attribute (with the same valueno), `client_id'. What I need is to search in both these databases and collapse results by `client_id' to get client IDs (set_collapse_key is used with collapse_max=1). The problem is that I receive 2
2006 Feb 10
2
How do I test actionview helpers in the console?
I would like to see the output of actionview helper methods, to be able to play with it. When I do the following in the console: collection_select("job", "client_id" , @clients, "id", "name") I get: NoMethodError: undefined method `collection_select'' for #<Object:0xb7cf1970> I''d like to get something like: <select
2006 Mar 22
4
Newbie - populating select list from db
Can''t seem to find an example of this anywhere - how do I populate a select list in a form from a database? I have a form to create a new task. The task is for a client, so there should be a select list populated from my clients table. I thought this would work: <%= select ''task'', ''client_id'', Client.find_all, "id", "name"
2005 Dec 23
1
pagination problem
hey, i have this problem in the database i have 32 records and the sql filtered 4 records #getting the callerid records depending on the given paramaters and paginate it @callerid_pages = Paginator.new self, CallerId.count, 10, @params[''page''] @caller_ids = CallerId.find(:all, :conditions =>["geotags.firm_id = ? ", @firm_id], :order => " geotags.address1
2012 Jul 15
1
Facebook redirect
Hi everyone I have this Application witch won''t redirect, I think it''s because there is another redirect, I mean when i redirect to the FB url (https://www.facebook.com/dialog/oauth?client_id=439021042804757&redirect_uri=http://localhost:3000/) I know there is another redirect, but I can''t get rails to follow this redirect. I had tried to google it, but I
2013 May 14
5
Why joins queries make result readonly?
Are there any rationalies to make queries obtained by joining scope to be readonly? I read some old posts (pre-rails3) that joins adds additional columns to record so that ActiveRecord doesn''t know how to update that fields, but actually I don''t see that fields. For example I write model class Order < ActiveRecord::Base has_and_belongs_to_many :executors, class_name:
2019 May 22
2
weakforced: Possible to access the ip address of report/allow?
Hi I wonder if the information about the origin of report or allow can be accessed somehow. lt.remote gives the IP of the client trying to login but is there anything in lt which gives the ip of the system that connects to wforced? Thanks and have a good one -- tobi
2011 Jan 02
1
fb-connect -Missing client_id parameter
Hi, I used facebook connect in my application for login and registration process using authlogic + authlogic connect gem. It works good in local machine, but in server it shows the error message like this. { "error": { "type": "OAuthException", "message": "Missing client_id parameter." } } Pls provide some solution to fix
2015 Apr 25
4
Error writing CDR
Hi All I have dozens of these messages on CLI complaining about database connection and error writing CDR to disk. The curious thing is I can find them all inside the database. I "selected" them using uniqueid and manually compared each column with the cdr_adaptive_odbc.c error line. "mysqlcheck -a -e -v DBase" and "mysqlcheck -c -e -v DBase" both returned OK for