search for: brand_id

Displaying 14 results from an estimated 14 matches for "brand_id".

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
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'') . . .
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 correct, however chaining...
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 =>
2008 Jul 22
2
ActiveRecord Associations issue
...LL, PRIMARY KEY (`id`), KEY `FK_CARS_MODELS` (`model_id`), CONSTRAINT `FK_CARS_MODELS` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ); CREATE TABLE `webcars_development`.`models` ( `id` int(11) NOT NULL auto_increment, `name` varchar(64) NOT NULL default '''', `brand_id` int(11) NOT NULL default ''0'', `created_at` datetime default NULL, `updated_at` datetime default NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_idx` (`nome`), KEY `FK_MODELS_BRAND` (`brand_id`), CONSTRAINT `FK_MODELS_BRAND` FOREIGN KEY (`brand_id`) REFERENCES `brands` (`i...
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 its giving blank field -- Posted via http:/...
2007 May 30
2
newb trying to figure out ActiveRecord relationships
3 tables. item, brand, commercial item -------- id name brand_id name brand --------- id name commercial ---------- id item_id The idea is that a commercial will have one item. each item will have brand. and a brand may have zero to many items. I can''t figure out how to make the relationships for my models. Eventually, i''d like to be able t...
2006 Jun 30
0
Interpolation in association conditions broken; broken backwards-compatibility?
I believe it used to be possible to interpolate values into associations'' conditions with single quotes, but it isn''t anymore. has_many :widgets, :conditions => ''brand_id = #{brand_id}'' Anyone else remember that? It seems to have been snuffed out in changeset 3897 with the removal of interpolate_sql(@conditions) Was the change (and the fact that it breaks backwards-compatibility) known and announced or is it just an oversight? Once in awhile there&...
2010 Jun 17
1
Problem with options_for_select
Hi, I have a problem with the form select. In the value field I have the generated html... <%= f.select :brand_id, options_for_select([[''Brands'', 0]] + @search_brands.map { |b| [b.name, b.id]}), {:id => ''cbxBrand'', :tabindex => (@tabindex += 1)} %> This is the html: <select name="search[brand_id]" id="search_br...
2006 Jul 19
5
weird result for a custom attr reader!
...by_name("Canon") =>#<Brand:0x2429784 @attributes={"name"=>"Canon", "id"=>"1"}> Thats OK >>canon.specific_category_names.first =>#<SpecificCategoryName:0x24235a0 @attributes={"name"=>"WIDER", "brand_id"=>"1", "id"=>"1", "description"=>nil, "category_id"=>"7"}> then the strange things: >> canon.specific_category_names.first.name => "Wide" This should be "WIDER" since that the value from sp...
2006 Aug 09
1
Migrating a Field to External Model
...at 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 looks like this: #Migrate Product Brands add_column :products, :brand_id, :integer Product::reset_column_information Product::find(:all).each do |p| brand = Brand::create(''name'' => p.attributes[''brand'']) unless brand = Brand::find_by_name(p.attributes[''brand'']) p.brand = brand p.save! e...
2006 Jul 15
1
Relationship problem, newbie problem, need help!!
...B DEFAULT CHARSET=latin1; #---------------------------- # Table structure for shop_addresses #---------------------------- CREATE TABLE `shop_addresses` ( `id` int(11) NOT NULL auto_increment, `shop_id` int(11) default NULL, `shop_uri` varchar(200) default NULL, PRIMARY KEY (`id`), KEY `brand_id` (`shop_id`), KEY `brandsbrand_uri` (`shop_id`), KEY `id` (`id`), CONSTRAINT `shop_addresses_ibfk_1` FOREIGN KEY (`shop_id`) REFERENCES `shops` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- Posted via http://www.ruby-forum.com/.
2006 Feb 15
3
Like Query Across Multiple Tables
Firstly, I''m still learning Ruby and rails, so there could be a very simple solution to this. I want to search across multiple tables with a "like" query eg: (SQL is probably the easiest way to describe it): select products.* from products inner join brands on products.brand_id = brands.id where products.name like ''%canon%'' or brands.name like ''%canon%'' Currently, I have a solution for only the products table. In the product.rb I have: def self.search(search_string) find(:all, :conditions => ["...
2005 Nov 30
8
nested attributes with update_attributes()
Hi, I am trying to use the update_attributes on object with nested attributes and I am getting the following error: ProductPrice expected, got HashWithIndifferentAccess Here''s the situation (simplified): class Product < ActiveRecord::Base belongs_to :productPrice end class ProductPrice < ActiveRecord::Base has_one :product, :dependent => true