similar to: newb trying to figure out ActiveRecord relationships

Displaying 20 results from an estimated 7000 matches similar to: "newb trying to figure out ActiveRecord relationships"

2008 Jul 22
2
ActiveRecord Associations issue
Hello all and thank you for reading this message. I am new to RoR, and ruby too, but i am quite excited about it. I am developing a RoR project and with active record associations in the following manner # Tables (all tables have only one record) CREATE TABLE `webcars_development`.`cars` ( `id` int(11) NOT NULL auto_increment, `model_id` int(11) NOT NULL default ''0'',
2012 Mar 28
1
collection_select
_form.html.haml = f.label :Select_Brand, "Select_Brand<em>*</em>".html_safe = collection_select(:brand_name, :brand_id, Brand.all, :id, :name, :prompt => "Select a Brand" ) show.html.haml file %table %tr %td Brand_Name : %td = @message.brand_id After writing this code I am not able to see the brand name. Its not giving any error but
2009 Jun 02
9
XML::LibXML::Reader
is there anybody who knows how we can get child values using libxml (Reader class) def xml_import_to_brands require''xml'' reader = XML::Reader.file(''c:/brands.xml'') . . .
2006 Sep 28
15
Inserting rows into linking table
Hi, I have two objects: Contacts Lists I want to be able to add multiple contacts to multiple lists. I''ve created a linking table and a form that allows me to select the contacts using checkboxes, but I''m having some problems with the controller and model. I receive the following error message when I submit the form: Mysql::Error: Cannot add or update a child row: a
2006 Aug 09
1
Migrating a Field to External Model
I have a model Product with an attribute ''brand''. Currently it is a simple attribute, however, I am migrating it to a separate model Brand so that I can have other attributes with each brand. I created the the model and created and ran the migration to create the new table. So far so good. Then I created a separate migration to transfer the data. The up method
2009 Jul 23
11
Problem with named_scope
Here are my scopes: default_scope :order => ''posted_on DESC'', :conditions => { :status => ''visible'' } named_scope :positive, :conditions => { :rating => ''positive'', :status => ''visible'' } named_scope :neutral, :conditions => { :rating => ''neutral'', :status =>
2007 Mar 28
4
Disabling ActiveRecord "type" column subclassing
Hi! I have a legacy table that has a column named "type" and need to remove this automatic subclassing by ActiveRecord. The api pages are vague about this, and I tried self.inheritance_column = "xtype" which seemed to get me half-way. In the validate_on_create method, the value of self.type was my model Class name. How would you disable this feature? -- Posted via
2012 Aug 31
3
Feature Request: Auto-infer .includes from .where with ActiveRecord queries
In the following snippet, can''t the includes being inferred from the where clause? Order.includes(:items).where(:items => { :category => [1,2,3] }) Can''t the includes be inferred from the where clause? Order.where(:items => { :category => [1,2,3] }) Would this conflict with any existing usages of the where clause and hashes? -- You received this
2011 Feb 17
1
Select distinict on not chainable with order method
Hi. I would like to do code refactoring: @beers = [] Beer.all.each do |beer| unless @beers.find{|c| c.brand_id == beer.brand_id} @beers << beer end break if @beers.size > 29 end So I achieved this by writing scope (on PostgreSQL): scope :with_unique_brand, select("DISTINCT ON (beers.brand_id) beers.*") Using this scope alone is working
2006 Mar 29
3
Self-referential many-many joins with :through
I thought I had this nailed but.. now I''m seeing spots.. I''ve included my models below, feel free to ignore them. I''m really just after an example that works. I couldnt find one on the wiki... which is fair enough considering Ricks patch: http://dev.rubyonrails.org/changeset/4022 that fixed them only went through 5 days ago.. Cheers -henster
2006 Jun 03
8
confused about ActiveRecord relationships
I am very confused about where to put the belongs_to and the has_one (and other relationship identifiers). I have read the RDoc and the agile book many times about this and I think i still see it backwards. Let me outline my app so you have an understanding... I have 2 tables: Schools { id, school_name, address_id } and Addresses { street1, street2, city, state, zip, country } *** this
2006 Jul 15
1
Relationship problem, newbie problem, need help!!
Hey all I seem to be having some problems with my relationship between a few tables... If i then run the following query in mysql, i get the data i want. How do i do this in rails relationships and models? select * from shop_addresses left join shops on shops.id = shop_addresses.shop_id left join styles on styles.id = shops.style_id where shop_uri = ''127.0.0.1'' Cheers!!
2013 Jan 25
3
how to delete the null elements in list
HI, I have the list: > suu [[1]] NULL [[2]] NULL [[3]] item_id prod 1 2 [[4]] item_id prod 1 2 2 4 how to delete all "NULL" elements from suu to get only >suu [[3]] item_id prod 1 2 [[4]] item_id prod 1 2 2 4 ?? Kind regards, Tammy [[alternative HTML version deleted]]
2006 Apr 10
4
Many To Many''s Join table attributes + migrations
Hi all, just joined and have only just kicked off with Rails (coming, but not departing, from WebObjects development). And so far there seems to be a lot of promise except for one thing I can''t figure out as yet -- the above problem. Say I have the following conceptual relationships: ITEMS <<--->> CARTS i.e., each item can belong to one or more categories. So really
2006 May 16
9
Array in database?
Hello, I wanted to know how to make an aray in the database. I''m making a "backpack" for my game. So i''m gana use it in a array. -- Posted via http://www.ruby-forum.com/.
2006 Apr 18
6
Postgresql and ActiveRecords problems
Hi all. I have a problem with postgresql PK columns and ActiveRecord. The error is: PGError: ERROR: null value in column "item_id" violates not-null. Ok, it''s wrong to insert NULL into PK columns, but rails doing it. How to fix? So sad..
2008 Jan 13
3
right usage of bdrb
Hi, i''m going to implement a syndication-service, which will get lists in xml with some meta-data an enclosed video files, which will get encoded at the end. The syndication run will be startet every five minutes of a full hour. So i thought to build 4 Worker. One for checking which feeds to syndicate (syndication_worker) at a specific time, one for processing the list
2006 Jan 05
2
Rails Newb: Foreign Key Views?
I''m a total rails newbie, but I''m learning fast. I have a question that I can''t seem to find an answer for: What is the best way of coding views that represent foreign key relationships? For example, while developing, I''ve created an "articles" table. I create some scaffolding code and modify it all to look nice. I then realise, I need an
2006 Dec 11
2
join and sort on 'best match'
Hi Everybody, I have been breaking my head on the following problem: how to join 2 tables and sort the results on the best match. explanation: - there are 3 tables, items, tags and items_tags. The items_tags table links items to tags. - I have one item which has certain tags, and I want to look up all the other items that have those tags as well - results should be sorted and presented by
2007 May 28
5
CTI in ActiveRecord
I search an plugin or gem, but don''t find nothing satisfactory. I believe to be stranger a technology that nails the DRY, have that create you vary equal tables, instead of using inheritance. Exists an soluction for this? I want a solution similar to this: create_table :people |t| do t.column :name t.column :address end create_table :customer |t| do t.column :person_id