similar to: Nested find(:all, :include => ) statements

Displaying 20 results from an estimated 600 matches similar to: "Nested find(:all, :include => ) statements"

2006 Mar 14
5
GROUP BY and SUM
I have orders, order_items, and products. I want to collate several orders so that I can get a SUM of quantities ordered for each product etc. Can I say something like (the below gives an error on :sum, and ignores :group) OrderItem.find(:all, :sum => ''quantity'', :group => ''product_id'', :include => [:order, :product]) I want to get back a
2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
I seem to be missing something trying to use ''validates_inclusion_of'' to validate a foreign key and was hoping some one could piont out my mistake? The problem seems to be that Order.find_all.collect is not returning an array that contains the order_id, if I replace it with a hardcoded array everything works as expected. The model: class OrderItem < ActiveRecord::Base
2006 Apr 14
3
Updateform with a has_many relationship ?
Hello all, I would like to be able to update the "amount" of a certain item in me order list. The problem I run into is how to define the text_field element. @order is the current order, which has_many :order_item which in turn belongs_to :order. order_item has a field "amount" which should be modified... What I tried is this below, but I get a undefined method
2006 Jul 06
7
form_remote_tag submitting to an rjs file.
I have the following form that I am trying to use, but for some reason, the form gets submitted with out the params values. <%= form_remote_tag(:url => { :action => :add_item_to_order }) %> <tr> <td> <%=collection_select(:order_item , :item_category_id, @item_categories, :id, :name)%> </td> <td> <%= text_field
2006 Jul 17
14
REST Relationship Models
I''m trying to figure out an elegant way to do this: I have the following three tables: people, employer, employees And consequently the following three models: class Person < ActiveRecord::Base end class Employer < ActiveRecord::Base has_many :employees end class Employee < ActiveRecord::Base belongs_to :person belongs_to :employer end I want to be able to say:
2006 Feb 14
7
Launching a standalone Rails app
Hi, I''ve developed a standalone Rails app - using tar2rubyscript and rubyscript2exe. The users aren''t going to understand that the''ll need to open the browser and go to 127.0.0.1:3000 to view the app, after running the exe. I am wondering whether other people have tackled this problem in the past, and how they went about solving it. One way would be to write a
2006 May 31
7
How to render from with <%%> ?
I have a loop that I iterate through in my view. <% coll.each do |itm| puts(itm.value) end %> How do I render the itm.value without using a <%= %> tag? Should puts not work? Joerg P.S. There is a good enough reason for me wanting to do this :-) -- Posted via http://www.ruby-forum.com/.
2006 Jan 22
3
Download an Image using Net::HTTP
Hi, I need to download an image, and I''ve mucked about with Net::HTTP resp = Net::HTTP.get_response(''www.mydomain.com'', ''/test.jpg'') f = File.new("test.jpg","w") f.write(response.body) And various other combinations using HTTP.get etc. Anyway, I get an image, but it looks very psychedelic. This is obviously not the correct way.
2008 Jun 04
2
Mock with an attributes that has state
I''m developing a rails application. I have an Order model that has_many OrderItems. I mocked the OrderItem model in my Order specs using mock_model. I thought I should focus my specs on each model and always mock associated models. In my Order model I need a way to merge OrderItems which have the same cost and same product_id. That I can spec. The other thing this merge helper
2006 Jan 12
8
Synching between Sqlite and MySql
Hi folks, I am running an offline Rails app that periodically connects to the Internet to download the latest catalogue, and upload any new orders. I am about to implement the synching bit - and was thinking whether there is any other solution other than writing webservices and code to do a manual sync of the data, or whether there is a more nifty and robust way using say replication?
2005 Apr 13
2
Creating multiple option groups
I''m setting up a basic shopping cart type app, and the products we have will have multiple options. Size, color, etc. I''m trying to figure out how I can collect the the options that are selected when a user adds the item to their cart. An OptionSet is a group of options ("Size", "Color", etc), and an ItemOption is the option itself ("12 oz",
2005 Dec 30
2
newbie
Hello There I new to rails development and looking to write a simple site using rails. Does any one know of and example ecommerce application that that I can use as a base to build from. My db schema is very simple--product, categories, orders and order_item tables. Any suggestions will be highly appreciate. Thanks Pat
2005 Dec 25
2
[repost] newbie questions
Hi all, I''m following the shop example in ''Agile Web Development with Rails''. I would like to extend the checkout screen, in such a way people can change the number of items they have selected in there cart. In my controller I have: def checkout @cart = find_cart @items = @cart.items if @items.empty?
2006 Mar 18
3
Nil result on find & pretty print
I am new to Ruby and to Ruby on Rails and have spent the last few days trying to get my head around it. I think I am already hooked but am suffering badly from years of programming a non-OO RDBMS. I am trying to learn by attempting to produce a system for my work. I have a main table sdocs which has a field supplier_id which is an entry in another table (suppliers) to lookup supplier name etc.
2006 Jul 21
3
How can I create OrderItems that go in a Order?
I suspect my problem is similar to having an order and wanting to have order items as part of the order, so I''ll explain the problem in those more familiar terms and then explain what if anything makes my actual situation different at the end. In an Order lets say you have: shipping_address and a shipped bool. OrderItem has quantity and name So Order has_many :OrderItems, and OrderItem
2006 Aug 10
1
Passing parameters defined in a function or something
Hi, I have method I want to call ... it can receive * number of parameters. I also have 3 parms that I want to pass often, so I have defined them in a separate function: def my_params { :parm1 => 1, :parm2 => 2, :parm3 => 3 } end And I want to call my method like this: mymethod :parm4 => 4, my_params Now - this doesn''t work - as my_params is a hash of params, which
2006 Jul 19
2
SimplyRestful bug?
Hi I have my routes set up like this: map.resource :contact, :path_prefix => "/employers/:employer_id" so now when I view all contacts for an employer I go to: /employers/1/contacts That works. On that page, there''s a problem with the routes: new_contact_url translates to: /employers/1/contacts/new ... so that works. But, contact_url(@contact) gives me
2006 Jan 10
2
Returning :success or :failure to remote function calls
Hi, When calling remote functions (AJAX), I can test for :success and :failure. But how do I return a :success or :failure to my AJAX function call from my action? Thanks Joerg -- Posted via http://www.ruby-forum.com/.
2006 Jan 20
2
AWS and passing in a Model
Hi, I have a webservice. And I want to pass in, a model. So, for example: api_method :save_person, :expects => [Person] When I do this I get an error saying that I cannot have ActiveRecord objects as parameters. Fine. I can have AWS Structs as parameters. I don''t want to start ''maintaining'' a struct everytime I change the table structure od Persons. So, is
2006 Apr 13
10
Typo and acts_as_ferret rebuild_index errror
Hi, I''m running the edge Typo and the latest acts_as_ferret plugin and ferret gems (as of 11 April). In my Content model I put acts_as_ferret :fields => [:title, :body] In the console, I call Content.rebuild_index to index all of my existing content. All the directories get created etc, but I get the following error back: Loading development environment. >>