search for: category_ids

Displaying 20 results from an estimated 181 matches for "category_ids".

Did you mean: category_id
2010 Mar 27
2
Shorter Rails 3 routes
Hi, I have a small 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)
2008 Jun 10
5
Rails params parsing bug?
I have a form that sends the following query string to my Rails controller: transaxion[category_association_attributes][][category_id]=2& transaxion[category_association_attributes][][amount]=12& transaxion[category_association_attributes][][category_id]=1& transaxion[category_association_attributes][][amount]=8 But ActionController parses it as:
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 19
3
Special ruby language for describing sql conditions
I was brainstorming today about a smooth way to define conditions in an sql query, when the numbers of attributes increase, so does the uglyness. So instead of passing a hash, I thought you could specify the conditions directly in code. I hacked together some example code which actually turned out to work. The result is concise and pretty beutiful. def search(params) Ad.find(:all) do
2009 Sep 24
8
Drop down list ?
Hi Gurus, I''m trying to tackle a drop down list. I have category and item dbs, and they''re wired up with category has_many :items and item belongs_to :category, and an item has a category_id. I have this code in my new/edit.html.erb for item: <%= f.collection_select :category_id, Category.find_main, :id, :header, {}, :multiple => false %> And a pretty drop down list
2006 Jun 07
1
How do YOU read/update HABTM?
In my mind, it should work like this: <%= select ''item'', ''category_ids'', Category.find(:all).collect {|c| [c.name, c.id] }, {}, {:multiple=>true, :size=>20} %> Then Rails should automatically populate and update HABTM on that. As it is now, the above won''t work (I created a getter in item''s model that returns an array of ca...
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 =>
2007 Jul 02
8
Strange intermittent no search results problem
Hello, First the specs: ruby 1.8.6, rails 1.2.3, ferret 0.11.4, mongrel 1.0.1, mongrel_cluster 0.2.1 And the model''s aaf config: # Ferret search engine acts_as_ferret({:fields => {:name => {:boost => 10}, :summary => {:boost => 2}, :body => {:boost => 1, :store => :no},
2006 Jun 18
6
integer array columns
Postgres database. I have a categories table, with two columns id, and name. I have a recipes table, with a category_ids column. I want each recipe to belong to one or more category. in recipe_controller.rb I have this: def create @recipe = Recipe.new( @params[''recipe''] ) @recipe.category_ids = @params[''recipe''][''category_ids''].map{ |s| s.to_i } @rec...
2005 Nov 22
11
Building a conditions clause (for find) of multiple optional params?
I want to be able to find items according to various params - category_id, member_id, type_id, rating, etc. What I have now is something like: if(@params[''category_id'']) @items=Item.find(:all, :conditions=>["category_id=?", @params[''category_id'']) elsif(@params[''category_id''] and @params[''member_id''])
2008 Nov 10
3
to_xml and helper methods
Hi, I have an array with objects and I want to generate an XML like: <objects> <object> <category_id>1</category_id> <helper-method>result 1</helper-method> </object> <object> <category_id>2</category_id> <helper-method>result 2</helper-method> </object> </objects> The helper
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 May 11
6
ActiveRecord associations
Can someone clarify this for me? Suppose I have two tables like: class Company < ActiveRecord::Base belongs_to :category end class Category < ActiveRecord::Base has_many :companies end I understand that the belongs_to causes related companies to be read from the db when I ask for a category. I suspect SQL something like select * from categories, companies where category.id
2006 Mar 30
5
Heeelp - no idea what''s going wrong.
...nd the database configs are the same, the MySQL database is never updated. This is the form that''s used: <% for category in @categories %> <div id="fancy"> <input type="checkbox" id="<%= category.id %>" name="category_ids[]" value="<%= category.id %> > <%= category.name %> </div <for subcategory in category.subcategories %> <div id="indented"> <input type="checkbox" id="<%= subcategory.id %>&...
2006 Jan 03
4
validates_presence_of *_id attributes
Hi all, I am a newbie to Rails. Please enlighten me on how to do this appropriately, the Rails and the Ruby way: Suppose I have a Recipe model. Let''s simplify things and pretend that it has only 2 attributes, a :name and the other is a ''category_id''. In the recipes table, category_id is a foreign key to field id of table categories. We also assume that I have generate
2006 Apr 22
6
nOOb question: How to use find_all with form input data
Hello, I''m having a problem utilizing the find_all method with a value from a form. I keep getting the following error: Mysql::Error: #42S22Unknown column ''category_id11'' in ''where clause'': SELECT * FROM items WHERE (category_id11) The controller seems to be getting the correct data, but my key and value seem to be mashed together(it''s
2006 Apr 29
1
undefined method `category_id''
3: 4: <b>Category: </b> 5: <select id="item_category_id" name="item[category_id]"> 6: <%= options_from_collection_for_select @categories, "id", "category", @product.category_id %> 7: </select> 8: </p> 9:
2006 Jan 15
4
form inputs resetting on sumbit
I searched for forum for something about this but couldn''t find anything. For example I have this in my view: (you enter start/end dates from dropdowns, pick a category and a report is generated.) <%= start_form_tag :action => ''display_report'' %> From: <%= date_select ''report'', ''date1'' %> <br /> To: <%=
2009 Feb 21
3
belongs_to or has_many
2 tables Items and Categories Categories (id, name) Items (id, name, category_id) Category_id can be null, and there are Categories that has not an Item. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email
2010 Aug 15
1
Can save object via console, but not in app's controller
My app has a ''page'' model and a ''category'' model. ''Page'' belongs_to :category. ''Category'' has_many :pages. From the console I can create and save a page object with no problems: >> p = Page.new #<Page id: nil, title: nil, body: nil, created_at: nil, updated_at: nil, published: nil, read_counter: nil, category_id: