Displaying 20 results from an estimated 10000 matches similar to: "Sorting by multiple categories"
2006 Jul 07
2
many-to-many error
hey all. I''m trying to set up a many-to-many relationship with products
and categories.
I''ve got the product model (product.rb) set up:
class Product < ActiveRecord::Base
has_and_belongs_to_many :categories
end
and a similar one for category.rb
And I''ve got the tables set up -- products, categories,
categories_products
But when I load, I get: undefined method
2006 May 01
4
Find rows with associations in habtm
This may have been asked/answered before - if so, i apologise...
I have the following table layout in a habtm relationship:
------------ ----------------------- --------------
| products | ----| categories_products |-----| categories |
------------ ----------------------- --------------
What would be the best way to pull out all the products for a given
category? At the
2005 Jun 03
1
sorting on a habtm relationship
I have two tables ("products" and "categories") that have a
has_and_belongs_to_many relationship, and I need to be able to
arbitrarily sort products in the scope of a category using something
like acts_as_list. Problem is, since each product can belong to
multiple categories, it doesn''t work to use acts_as_list and have the
"position" field be in the
2006 May 28
7
Join table not being populated
Hello,
I have the usual Categories and Products table scenario, mediated by a
Categories_Products join table. When I create a new Product and into a
given Category, I notice that my join table is not being populated.
Shouldn''t the join Categories_Products table be populated?
Thanks,
gk
--
Posted via http://www.ruby-forum.com/.
2006 Jun 05
5
adding habtm through migrations
Hello,
I''m stuck, I''ve got a model Product and would like to add a new model
called Category. Furthermore, I want to set up a many2many
relationship between the mentioned models. the problem is that I do
not know how to set the primary key in the categories_products table.
this is what I''ve got in my migration file:
create_table :categories do |t|
t.column :name,
2006 Jul 30
1
Doubt on composite index
The AWDwR book has the following:
add_index :categories_products, [:product_id, :category_id]
add_index :categories_products, :category_id
The first, composite index actually serves two purposes: it creates an index which can be searched
on both foreign key columns, and with most databases it also creates an
index that enables fast lookup by the product id. The second index then
completes
2006 Jun 14
3
Prevent duplicate HABTM associations
Hi,
I am trying to restrict duplicate has_and_belongs_to_many associations.
I tried to find support for a association validation for duplicates but
couldn''t find anything.
I understand I could use :uniq=>true on the model association but this
would only prevent it from displaying duplicates, I want to stop
duplicate associations being inserted in the first place.
I have a vague
2006 Apr 16
11
Best way to sort categories w/ pager
Ahoy,
I made this pager,
" def list
@item_pages = Paginator.new self, Item.count, 10, @params[''page'']
@items = Item.find :all, :conditions => "category_id =
#{params[:condition]}",
:limit => @item_pages.items_per_page,
:offset => @item_pages.current.offset
@categories = Category.find_all
2006 Dec 30
4
newbie question, "show items in selected city and category"
Hi,
rails newbie needs help :)
I have classified ads (cads) related with cities and categories:
class Cad < ActiveRecord::Base
has_and_belongs_to_many :categories
has_and_belongs_to_many :cities
end
class Category < ActiveRecord::Base
has_and_belongs_to_many :cads
end
class City < ActiveRecord::Base
has_and_belongs_to_many :cads
end
I assume that user can act such
2006 Jul 26
1
How to create table entry with multiple related categories?
Perhaps I should create a table row to hold an array of category ID''s?
There''s probably an easy standard way of doing this in RoR and I just
can''t wrap my brain around a practical way to do this right off.
Specifically...
I have a table that contains my product category names and another table
that contains my actual product names with other product specific
2006 Feb 13
2
categories and admin/categories - different controllers and templates?
Is there some way to have these two sets of URLs use
totally different controllers and templates?
categories/list
categories/show/1
admin/categories/list
admin/categories/edit/1
admin/categories/destroy/1
admin/categories/update/1
Besides, of course, using different controller names
;). The first URL is publicly accessible, while the
second contains admin functions. Also, with the
second,
2006 Jan 06
3
Cookbook recipes eg - ordering categories in the recipe pull-down box
People,
I can order categories when looking at the categories list page but how
do I change the recipe page to list the categories in alpha order in the
recipe pull-down box?:
> <p><b>Category:</b><br>
> <select name="recipe[category_id]">
> <% @categories.each do |category| %>
> <option value="<%= category.id
2006 Jul 06
5
Single table inheritance
I''m having a class called Person, with subclasses as goalkeeper,
forward, defender.
Now a person can be a forward as well as a defender or a goalkeeper.
I want to use single table inheritance like :
class Goalkeepr < Person
end
And not have multiple boolean columns like in my people table like is
is_goalkpeer, is_forward, is_defender.
How do I go about it ?
Thanks,
Pratik
--
rm
2006 Mar 10
8
multiple sub categories (parent-child)
hi.
base from the cookbook example, where each categories can have many
recipes,
id like the categories to have multiple sub categories, unlimited
levels.
please show some code, as i am new to Ruby and Ruby On Rails.
thanks
--
Posted via http://www.ruby-forum.com/.
2006 Jun 17
5
Having trouble listing tiers of categories
I have categories and sub-categories in a table called "categories".
Every row has a "parent" field to note if the entry is the sub-category
of another (never goes deeper than 1 level).
So there might be something like this:
id | name | parent
1 Dog 0
2 Pug 1
3 Siamese 5
4 Shih Tzu 1
5 Cat 0
6 Wiener Dog 1
7 Persian
2008 Nov 17
1
delete categories
I have a dataset which has categories A-G (7 categories) with corresponding
x and y variables. I want to delete one category from the dataset and run a
logit model on only 6 categories instead of 7. How do I delete a category? I
have tried the omit command but it just returns TRUE and False values.
[[alternative HTML version deleted]]
2013 Nov 07
1
problem with interaction in lmer even after creating an "interaction variable"
Dear all,
I have a problem with interactions in lmer. I have 2 factors (garden and
gebiet) which interact, plus one other variable (home), dataframe arr. When
I put:
/
lmer (biomass ~ home + garden:gebiet + ( 1|Block), data = arr)/
it writes:
/Error in lme4::lFormula(formula = biomass ~ home + garden:gebiet + (1 | :
rank of X = 28 < ncol(X) = 30/
In the lmer help I found out that if not
2012 Oct 19
3
Newly installed version; can't run lm function
New installation seems to have behavior I cannot figure out. Here is illustrative sequence where I load a small data set (test) from Crawley's files and try to run a simple linear model and get an error message. Oddly, R reports that the variable 'test$ozone' is numeric while, after attaching test, the variable ozone is not numeric. Can someone please help? This behavior is
2006 Jul 07
5
Can a route require POST or GET? / REST problem with routing
Hi,
A store front a customer wants to GET /product/5/show. But for the
application this is really GET /cart_item/new/5 or even better
/cart_item/new?cart_item[product_id]=5
When the customer clicks add_to_cart they POST /product/5/show so that
the url doesn''t confuse the user when any validation errors occur. But
for the applicaiton this should be POST
2007 Mar 03
2
Could patch #7703 (SQL Server bug fixes) be applied?
I''ve packaged three small SQL Server bugfixes into patch #7703, and
tested against SQL Server 2000 and 2005.
Would a member of core mind applying this patch? Once this is done,
I''ll start looking at some of the other SQL Server tickets.
Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups