search for: category_id

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

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_arti...
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: category_association_attributes" => [ {"category_id&qu...
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
...= params[:area_id] if params[:area_id] && params[:area_id].to_i > 0 conditions.kind = params[:kind] if params[:kind] conditions.selling = params[:selling] || 1 conditions.approved > 1 conditions.year.include?(2004,2005) conditions.or do |conditions| if params[:category_id] && params[:category_id] > 0 conditions.category_id = params[:category_id] conditions.parent_id = params[:category_id] end end end end p(search( :area_id => 0, :kind => ''f'', :category_id => 13)) # => "ads.kind = ''f''...
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 comes up, but no matter what I do, I can''t save an item with a different category--it always stubbor...
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 c...
2006 Jun 14
13
Undefined method
...ion (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 I have a belongs_to : category In the Category model I have a has_one : position I was under the grand illusion th...
2007 Jul 02
8
Strange intermittent no search results problem
...gt; 1, :store => :no}, :question => {:boost => 1, :store => :no}, :answer => {:boost => 1, :store => :no}, :status_id => {:boost => 1}, :category_id => {:boost => 1}, :published => {:boost => 1}}, :store_class_name => true, :remote => true, :ferret => { :analyzer => Ferret::Analysis:: StandardAnalyzer.new([]) } } )...
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 } @re...
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[''memb...
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 method generates some urls...
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 comp...
2006 May 11
6
ActiveRecord associations
...ory 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 = myid and companies.category_id = category.id but what SQL results from the has_many? -- Posted with http://DevLists.com. Sign up and save your mailbox.
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 the appropriate scaffolding code for Recipe and Category. All goes well if I go to http://localhost:3000/categories (I''m using WEBrick) and add a new Category...
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 mashed-hash? ) I''m using a pulldown box that contains a list of the categories....
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
...rt_form_tag :action => ''display_report'' %> From: <%= date_select ''report'', ''date1'' %> <br /> To: <%= date_select ''report'', ''date2'' %> <br /> Category: <%= select(:report, :category_id, @categories) %><br /> <%= submit_tag ''Show Report'' %> <%= end_form_tag %> When I submit this form (back to the same action) all of the dropdowns are reset to default values, instead of what was selected. I haven''t had problems when editing a AR...
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 thi...
2010 Aug 15
1
Can save object via console, but not in app's controller
...''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: nil> >> p.title, p.body, p.category_id = "Test", "Test", "1" #<Page id: nil, title: "Test", body: "Test", created_at: nil, updated_at: nil, published: nil, read_counter: nil, category_id: 1> >>p.save => true Yet, when I s...