Displaying 20 results from an estimated 100000 matches similar to: "sql caching"
2009 Mar 11
0
Is there a better way to do this (SQL groups)?
I have a Task model and a Category model with belongs_to and has_many.
What I want is to get from de DB the tasks in groups of categories and
each one of this groups with a maximum of 5 tasks. Later, I want to show
this in tables; each table will be a group.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are
2007 May 24
4
design patterns
Hi everyone
I''m Maximiliano Guzenski from Brazil and I am programing on ruby on rails
only a couple of months.
I read a lot of books and articles about it but I could not clarify some
doubts about design patterns:
1) Is it really good put some sql command on controller? because all
articles that I see use sql into controllers, like:
# my controller
@categories = Category.find
2008 Dec 16
1
Callback when objects connect as a habtm relationship
If Product and Category models are in a habtm relationship, i.e.
class Product < ActiveRecord::Base
has_and_belongs_to_many :categories
end
class Category < ActiveRecord::Base
has_and_belongs_to_many :products
end
I want a piece of code to be executed every time a product is connected to a
category.
Where do I put this code? Which callback (and on which model) will be
triggered?
Any
2007 Nov 21
0
Expiring page caches with regexp?
Is there a way to expire page caches using regular expressions like
you can with fragment caches?
I''m writing an app which has a catalogue style product listing but not
full on e-commerce. It''s pretty simple; with just categories and
products within them. A url for a product called "Band Saws" within
the category "Heavy duty saws" would look like
2010 Dec 20
11
rails code to sql
Is there a relatively easy way to do this code in sql?
@categories=Category.all.reject{|n| n.blank?}.sort{|a,b| a.name
<=>b.name}.collect{|t| [t.name,t.name.downcase.gsub('' '',''_'')]}
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2007 Sep 26
1
Is there a Rails helper similar to link_to_remote but for a form check box instead of a link?
I''m working on a couple of user input forms -- one data entry, one
search -- where I''d like to start off by displaying only top-level
categories. Then, if a user checked one of the top-level categories,
all the child categories would show for that top-level one.
(Displaying all the child categories for every parent would be a bit
overwhelming, it''s a large list.)
I can
2007 Feb 08
3
Get categories where forum-user posted in
I''m developing a system similar to the ForumExample (http://
wiki.rubyonrails.org/rails/pages/ForumExample), and stumbled upon the
following.
Let''s say I wanted to get all the categories a certain user posted in.
How do I get that information withouth using a custom query
through :finder_sql (and thus losing the find_in_collection ownage)?
It would also be great to see how many
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 Dec 15
1
How can I have two controllers use the same 'category' model if they aren't related?
Hi all,
I have two controllers - "foods" and "receipes" which map to models.
Each one will have multiple categories, but the categories are
completely different for each one - they don''t share the same
category. So they aren''t related at all.
If I wanted to do this using resources, what is the best way to set
this up? If I setup a categories controller and
2008 May 19
2
x is not a number error??
I may be overlooking something really obvious here but I''m not getting
it. I have a Category model. Categories can have sub categories and
parent categories, but when a category doesn''t have a parent category,
its "parent_categoryid" field is set to null. As far as I know, what I
am doing here has been working in the past because there are many
categories in my
2009 Jan 15
4
HABTM and Check Boxes (Yet Another thread on this)....
Hi there,
it''s an afternoon that i''m destroying my head on this, and i''ve decided
to ask to you all .
I''ve got to do some check box lists for a modified substruct version i''m
doing, right now, i''m interested to insert a list of categories of
interests into a customer sheet
i''m using the substruct plugin version, wich stays in the
2008 Mar 12
1
Ordering across related tables
I have two related tables: groups and categories. In the models,
Group
has_many "categories"
Category
belongs_to :group
Category does have a column, "group_id" as required.
Both the groups and categories tables have a "sortorder" column which
dictates the order the items are to be presented.
In my controller, I want to retrieve the Categories
2007 May 11
0
categories like ebay
I think the category feature of eBay is very handy. I want to figure out
a way to to make this function work on rails.
What is so sepcial with ebay''s category feature?
Let''s say we are going to buy a Movie DVD.
HOME->BUY->DVDs & Movies
in ''Categories within DVDs & Movies'', click the first item ''DVD, HD DVD
& Blu-ray''. ok, now
2008 Dec 07
1
How to describe self join in a model
Hi ,
I am new to rails, and i need to know one thing, i have a table
called Categories and i want to self join it in such a way , that one
category could be a parent of many categories, but could be child of
only one category.
Please tell me how to tell rails , in my Category Model, does the
following work for me ?
class Category
belongs_to :category
has_many :categories
end
2008 Nov 27
3
A topic on a category of a subforum really belongs_to what?
Suppose you have a forum with many sub-forums, and each sub-forum has
many categories (or sub-sub-forums), and each category may or may not
have many sub-categories (or sub-sub-sub-forums).
Will a topic belong to the sub-category AND category AND sub-forum; or
only to a sub-category, that will in turn belong to a category that will
in turn belong to a sub-forum?
--
Posted via
2007 Jul 22
4
single table inheritance problem
Hallo,
I am having a very strange Problem with STI in my application.
setup:
- two tables one called "wikis" on called "categories" with a hbtm
relationship.
- the wikis table is the sti one with a model PageWiki being extended
from Wiki (and the correspondig type column)
Following happens:
- server restart
- get :wikis, :show_pages
- in show_pages the first line says
2009 Apr 12
0
rails 2.3 nested forms with has_many through checkboxes
I was wondering if anyone knew of a way to combine the new nested
forms in rails 2.3 with a has_many through relationship via
checkboxes. Basically I have a page model, a page_category model and
a category_items join table. Pages have many page categories through
category items. The category_items table is polymorphic so i can use
it for other models who need categories (maybe this is
2007 Feb 14
3
eager loading parents and children (acts_as_tree)
I am struggling with how to do eager loading of an acts_as_tree model.
If the model Stuff acts_as_tree I know I can do this to get children as
well:
Stuff.find(:all, :include => :children)
But what if the model I am including is the one that acts_as_tree?
For example, say Picture belongs_to Category. Category acts_as_tree and
I want to get all pictures that are members of a category that
2008 Feb 02
3
sort notes by category (when category is stored in notes)
okay, breaks the relationship model but it''s a really simple data model
so doesn''t need too much about it.
here''s my structure, I have a notes model containing...
note:
name, date, category
so each note will have it''s own, name, date and category (with some of
the categories being the same, hence sort by...)
now i could sort by category easier by having the
2008 Nov 14
3
migration with data
Hi
I am using postgres and have two migration files like
001_create_categories.rb as
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.column :name, :string, :limit=>80
end
end
def self.down
drop_table :categories
end
end
and 002_populate_categories.rb
class PopulateCategories < ActiveRecord::Migration