similar to: parent - child help (RoR & MySQL)

Displaying 20 results from an estimated 1200 matches similar to: "parent - child help (RoR & MySQL)"

2006 Aug 14
1
What fields_for really for?
Hello everyone! I have 3 models: === 1 === class Region < ActiveRecord::Base has_many :districts end === 2 === class District < ActiveRecord::Base belongs_to :region has_many :suburbs end === 3 === class Suburb < ActiveRecord::Base belongs_to :district validates_numericality_of :region_id, :only_integer => true end In edit.rhtml for SuburbController I need to specify
2007 Aug 20
0
FormBuilder in rjs
I have a page, which renders a partial that contains a ''State'' drop down list. Upon change, it re-renders the ''City'' drop down, re- populating it based on selected state_id: Page: /customer/new.rhtml <% form_for :customer, :url => customers_path do |f| %> State: <%= f.collection_select :state_id, State.find(:all), ''id'',
2012 May 28
4
How to load a selection list into the method new of a controller?
Hi friends! I''m relatively new with Rails and I''m struggling for a long time with this problem (it should have a pattern solution but until now I didn''t find it): I have the following models: Institution, City, State and Country. class Country < ActiveRecord::Base has_many :states has_many :cities, :through => :states end # == Schema Information # Table
2006 Jan 31
2
Relationship navigation issue
class Event < ActiveRecord::Base belongs_to :venue belongs_to :category end class Venue < ActiveRecord::Base belongs_to :city end class City < ActiveRecord::Base belongs_to :state end I want to retrieve all event records belonging to a state. Coming from hibernate background I tried something like this: def self.list_for_a_state(state_id) find_by_sql(["select e.*
2009 Nov 06
0
Nested objects not propagating from view
I thought I had this fixed, but apparently not. It works okay from the console, but not from the view. I have the following: # partial schema create_table "users", :force => true do |t| t.string "login", :null => false t.string "first_name" t.string "last_name" t.string "email", :null => false
2006 Mar 11
0
Using :joins - How to help Rails populate a list of records from a complex join
Hi, Due to some performance issues, I want to use a custom query for a find method: def find_in_state(state) State.find :all, :limit => 10, :conditions => [''s.id = ? AND '' + ''s.id = c.state_id AND c.state_id = ? AND '' + ''c.id = col.county_id AND
2006 May 28
3
Validating Foreign Key
Howdy, I''m a Rails beginner working on my first significant project with RoR. I''m trying to figure out how to validate a foreign key (you know, make sure the row actually exists.) However, validates_associated doesn''t seem to be what I want to use, nor does it work... -- BEGIN -- class City < ActiveRecord::Base has_many :schools belongs_to :state
2006 Aug 16
1
how to update a collection_select from another
I have two collection_select in my list.rhtml: <%= collection_select (:region, :id, @regionall, :id, :title,html_options={:onChange => "new Ajax.Updater(''related_provinces'',''/categories/related_provinces/" + "?id=''+this[this.selectedIndex].value, {asynchronous:true, evalScripts:true});"}) %><br> <%= render :partial =>
2016 Nov 02
0
[PATCH v3 05/15] secboot: remove fixup_hs_desc hook
This hook can be removed if the function writing the HS descriptor is aware of WPR settings. Let's do that as it allows us to make the ACR descriptor structure private and save some code. Signed-off-by: Alexandre Courbot <acourbot at nvidia.com> --- drm/nouveau/nvkm/subdev/secboot/gm200.c | 95 ++++++++++++++++++++++++--------- drm/nouveau/nvkm/subdev/secboot/gm20b.c | 11 ----
2006 Mar 23
4
belongs_to more than one model
Suppose I have one table: states id statename And I have two other tables that contains states: houses id color state_id places id place_name state_id How would my model relationships look like? class State < ActiveRecord::Base belongs_to house belongs_to place end class House < ActiveRecord::Base has_one state end class Place <
2006 Jan 11
6
How to display the error messages from the controller
I have a wizard which consists of two pages. To keep it simple let''s say that the first page asks the user to select a state from the drop down menu. In case the user doesn''t select any state, an error message needs to be displayed. Ideally I would like to do something like this. def new selected_value = params[:addevent][:state_id] if selected_value == "-1"
2012 Mar 22
1
Rspec not loading fixtures
I am taking over a code base and am trying to run the tests. I am somewhat new to RSpec so this might be a trivial problem. Basically I can tell that the fixtures are not getting loaded. All 100 tests fail with a similar error. But I don''t know why. Below is the code, with my narrative with *** before it... Can you see anything or give me a clue where to look. So far I am coming up
2006 Apr 21
1
select box with multiple rows
I want a select box that displays 5 rows instead of one row and a drop down. so i figure this should work, but it doesn''t. <%= collection_select(:constellation, :region_id, @regions, :id, :name, html_options = {:size => ''5''})%> I am not quite sure how to use that html_options and googling around I didnt find anything directly on point. Any suggestions?
2006 Jul 14
20
Method for associated relationships
I have these tables set up like this: listings has_many :states <field>state_id [int] <other fields.... .............. .............> states belongs_to: listings <field>name <other fields.. ............... .................> In my view I have <%= listing.name %> have also tried listing.state_id.name , that didn''t seem to do the magic either. This
2006 Jun 26
2
DRY up selects in view
Here''s what I''ve got: <% @fields.each do |field_name| %> <tr> <td> <%= field_name.humanize %> </td> <td> <% unless field_name =~ /_id$/ %> <%= form.text_field field_name, :size => 40 %> <% else %> <%= select(:vendor, field_name, State.find(:all, :order
2012 May 03
1
Help with getting values from string
Hi All, I have a doubt. I used macros and i try to pass a value to a macro by concatenating a bunch of strings. But it does not seem to work. Please help. I have written down my code and the error message please tell me how to pass the value that a string points to. Thanks in advance #macro defined
2007 Jan 15
1
Using One Lookup Table for Multiple Model Properties
I have a model that has two properties that both come from the same database table. Let''s say I have a "Lead" model. This Lead has both a contact "State" (as in Colorado, Arkansas, etc.) and a "Property State" where the house he''s looking to refinance is located. Both of these should obviously be objects of the type "state".
2006 Jan 19
1
Populating a select field using observe_field
Hi, I''ve just started toying with Rails and AJAX, so forgive me if this is a bit of a stupid question. I''m trying to populate a select field when the value of another select field is changed. Looking through the API doc, it seems like observe_field is what I need. In my view I have: <p><label for="wine_country_id">Country</label><br/>
2011 Aug 22
0
Paperclip nested resources problem
My models: class Country < ActiveRecord::Base has_many :regions has_many :assets, :dependent => :destroy accepts_nested_attributes_for :assets end class Region < ActiveRecord::Base belongs_to :country has_many :appartments has_many :assets, :dependent => :destroy accepts_nested_attributes_for :assets end class Asset < ActiveRecord::Base belongs_to :region
2006 Mar 28
2
In_place_editor_field throws error ...
I receive the following error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id when trying to use the in_place_editor_field tag: <% for employee in @employees %> <%= in_place_editor_field :employee, employee.fname %> <% end %> My model is called Employee and is being populated from a controller method employees_list: