Displaying 20 results from an estimated 5221 matches for "category".
2006 Jul 08
2
Trouble getting select to work
I''ve tried pulling this together from examples in the book, searching
the web and this list, but so far I''ve not been able to get it working
just right.
My table is a categories table with id and category fields.
My form has the following:
<td><%= select(''category'', ''category'', @categories = Category.find(:all,
:order => "category").map {|cat| [cat.category, cat.category]}) %>
I used [[cat.category, cat.category] as I am not interested...
2010 Mar 27
2
Shorter Rails 3 routes
...blog application, and I would like to shorten its routes.
Here they are:
Blog::Application.routes.draw do
resources :categories do
resources :articles do
resources :comments
end
end
A rake routes command produce the following lines:
GET
/categories/:category_id/articles/:article_id/comments(.:format)
{:controller=>"comments", :action=>"index"}
category_article_comments POST
/categories/:category_id/articles/:article_id/comments(.:format)
{:controller=>"comments", :action=>"create"}
new_category_a...
2009 Oct 15
10
AJAX - how to have multiple select form sets implemented?
hi, there :)
Consider a blogging application whereby a user is trying to add a new
blog.
He/she has to select a category. Upon selecting a category from a drop
down box, a new sub categories drop down box will be created (hence an
AJAX call). Got this implemented and it''s ok.
Now, let''s assume that a given blog can have multiple categories (and
subcategories).
For example, a blog on a restaurant re...
2006 Jul 23
3
Newbie: Display hierarchical Records in a view
Hi,
I have two models: category and subcategory. (one to many
relationship), and a controller ''home''
I''d like to display all the categories and their sub categories in the
view: home\index.rhtml.
I have a method in the ''home'' controller'' like this:
def list_categories
@c...
2006 Mar 31
7
Checkboxes expand to show new options when checked?
I''m writing a simple CMS where every item ("listing") HABTM categories
and subcategories (which themselves belong_to a category). What I''m
trying to do now is create a UI effect for listing creation: when you go
to create a listing, only the possible categories will be shown, but
when you select a category a set of new categories will be displayed
like so:
Lions
Tigers
Bears
> click on Tigers
Lions
Tigers...
2006 May 31
3
instance variable problem
...s it just render the template or should I
have the instance variable as well also? I''ve tried changing it to
redirect_to and it doesn''t error, but also doesn''t provide the error
messages I want.
I''ve got this in my ImageController:
def new
@categories = Category.find(:all)
end
def create
if request.post?
@image = Image.new(params[:image])
@image.categories = Category.find(params[:category_ids]) if
params[:category_ids]
if @image.save
redirect_to :action => ''list''
flash[:notice] = ''...
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 way: first, from cities listing, which
is produced by ''list'' method in cities_controller, the user chooses
city...
2006 Feb 13
4
Calling find()
Hello, sorry for the bulk question, but I cannot find answer anywhere,
I have model like Phonebook::Category, and i`m stuck on calling find()
method on this model ?
2007 Oct 09
2
fit.contrast and interaction terms
Dear R-users,
I want to fit a linear model with Y as response variable and X a categorical variable (with 4 categories), with the aim of comparing the basal category of X (category=1) with category 4. Unfortunately, there is another categorical variable with 2 categories which interact with x and I have to include it, so my model is s "reg3: Y=x*x3". Using fit.contrast to make the contrast (category 1 vs category 4) with options(contrasts=c("con...
2006 Apr 15
8
Inheritance in Rails - I need some help
I''ve got a model, "category" and another model "subcategory." Each
subcategory belongs_to a category, and a category has_many
subcategories.
What I need to do is set it up so that I can search Category and
Subcategory with one .find call. So:
Category.find(:all, <etc)
will find categories and subcatego...
2006 Mar 29
11
why belongs_to does not like validation?
This works :
class Recipe < ActiveRecord::Base
belongs_to :category
end
But (when I add validation) this does not work :
class Recipe < ActiveRecord::Base
belongs_to :category
validates_length_of :category, :within => 6..20
validates_uniqueness_of :category, :message => "already exists"
end
thank you
--
View this message in...
2006 Jan 10
5
Select Tag and Associations
Hi there,
I''ve been working on this for awhile and have finally decided to ask
for a little guidance.I have a slight problem trying to save a
selection.
I have two models:
A "Posting" has_many "Categories", and a "Category" belongs_to one
"Posting". With that said, in the posting model I have "has_many
:categories" and within the category model I have "belongs_to
:posting". That part I ''believe'' is correct, however I very well could
be off on that.
The columns in...
2006 May 03
3
Sorting by multiple categories
I have a database with a field called ''category''.
''category'' contains the categories separated by a "," i.e. 1, 2, 5
I know with something like:
@products = Product.find(:all, :condition => "category = ''1''")
I could get some results if any of the ''category''...
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 5
I''d like to list it like
Dog
--Pug
--Shih Tzu
--...
2006 Jun 14
13
Undefined method
I really hope this is not a bad question (as in he''s abusing the
list). However I could use a little direction (even though I''m
reading books, tutorials)
Right now I''m getting a
undefined method `category'' for 4:Fixnum
The specific lines from the rhtml file are:
<td><%= link_to position.category_id.category, :action => "show", :id
=> position.id %></td>
The "link_to position.category_id.category" is the real problem.
So,
In the Position model...
2006 Apr 15
7
New to rails - scaffold command , how to get related items?
...e tutorials and build a simple to-do list program
with Items and Categories and have the related tables link up w/ the
default "scaffold :Items" command plus custom defenitions.
Then I erased all of that and tried rebuilding the program using the
ruby script/generate scaffold Item (and category) command.
Now the templates look like
"
<% for column in Item.content_columns %>
<td><%=h item.send(column.name) %></td>
<% end %>
"
And putting
"
<td><%h item.Category ? item.Category.name : "no category" %></td>...
2006 Jan 26
4
Override has_many :order at run-time?
Is it possible to override has_many''s :order attribute at run-time? e.g.
something like:
<% for category in @site.categories(:order=>''name'') %>
...
<% for category in @site.categories(:order=>''rank'') %>
...
thanks
csn
--
Posted via http://www.ruby-forum.com/.
2006 May 04
2
Building a FAQ
I''m new in Rails, and I''m building my first application. I''m trying to make
a FAQ for this application, organized by product (questions about each
product) and category (questions of different categories or topics), and
there is something I can''t figure it out how to do.
I have these tables:
create_table "faqs" do |t|
t.column "question", :text
t.column "answer", :text
t.column "product_id", :integer
t.col...
2005 Sep 23
6
problem with acts_as_tree
Hi,
I''m using the latest gem version of rails under MacOS Tiger.
I was trying to use acts_as_tree as described in the rails book. So
I have something like:
class Category < ActiveRecord::Base
acts_as_tree :order => "title"
end
create table categories (
id int not null
auto_increment,
title varchar(100) not null,
parent_id int,
constraint fk_category...
2016 Jan 20
4
[3.8 Release] RC1 has been tagged
...ample, recently with trunk r256945, I saw these:
Failing Tests (39):
libc++ :: std/depr/depr.c.headers/stddef_h.pass.cpp
libc++ :: std/depr/depr.c.headers/wchar_h.pass.cpp
libc++ :: std/language.support/support.types/max_align_t.pass.cpp
libc++ :: std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
libc++ :: std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp
libc++ :: std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
libc++ :: std/localization/locale.cate...