Displaying 20 results from an estimated 100000 matches similar to: "Using :group in find method"
2006 Mar 13
8
Nested find(:all, :include => ) statements
Is there a way for me to do:
OrderItem.find(:all, :include => [:user, :product => [:supplier]]
So I don''t have a supplier_id on my order_item, but have it on my
product, which is part of order_item.
Joerg
--
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.
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 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 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 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 30
2
Rake and NOT using schema.rb for clone_structure_to_test
Is there a way to specify not not use schema.rb but instead using a
native sql file to clone structure to the test db? Schema.rb doesn''t
really work that well for mediumblobs ... Thanks.
--
Posted via http://www.ruby-forum.com/.
2008 Feb 25
4
Using group in with find in an ActiveRecord appropriately
I''m playing around with the Practical Rails Projects code, and was
attempting to make a change for graphing data differently using
groupings.
Basically the code went from:
total_weight = @exercise.activities.collect {|e| e.repetitions
* e.resistance}
workout_dates = @exercise.activities.collect {|e|
e.workout.date.to_s}
To:
total_weight =
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?
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 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 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 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 Jul 02
0
Rails Core Weekly June 19 - July 2 2006
This is another edition of Rails Core Weekly, affectionately known as
RCW. A much nicer pre-web 3.0 version is available from the following
url :
http://www.pinupgeek.com/articles/category/rails-core-weekly-news
We have an Atom/RSS feed available there as well.
Rails Core Weekly summarizes the rails-core mailing list, a list
dedicated to Ruby on Rails internals and its development. RCW is
2007 Apr 15
1
unable to find inherited method for function "edges", for signature "ugsh", "missing"
I am new to using S4 methods and have run into this problem (on Windows XP using R 2.4.1): I am writing a package in which I use the graph package. I define my own classes of graphs as:
setOldClass("graphsh")
setOldClass("ugsh")
setIs("ugsh", "graphsh")
(I know that I "should have" used setClass instead - and I will eventually - but right now
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.
>>
2006 Aug 16
3
calculate method is gone once I use ''find''?
Could someone please explain why this works:
current_user.accounts.sum(:balance)
But not this:
current_user.accounts.find_all_by_active(true).sum(:balance)
For the latter Rails tells me sum is an undefined method. It seems like
I lose the ActiveRecord methods when I call ''find''?
This (simpler) does not work either:
current_user.accounts.find_all.sum(:balance)
Thanks!
--
2006 Feb 09
3
acts_as_taggable Produces Bad SQL - Find Fails
I am using acts_as_taggable in my application and on the tagging side of
things, no problem at all. Running edge Rails and PostgreSQL 8.1.
I am then trying to find all my AR objects with a certain tag. The tag is:
lasvegas and I know that there are at least 3 records with that tag.
So, I''m doing this:
@lists = List.find_tagged_with :any => @search_string, :separator =>
2006 Oct 23
1
find method use without sql in mind
I have a class Day with field date that represents a my sql date type,
YYYY-MM-DD. The Ruby type Date class has method, cweek, that returns
the calendar week that corresponds to a particular date. Ruby knows
cweek, but MySQL has no knowledge of this value. How do I run a find on
class Day, (Day.find :all ... ) with condition [date.cweek = ?, week]?
This is not a sql search but a Ruby
2011 Jun 04
3
[LLVMdev] [llvm-commits] Branch Probability
On Jun 1, 2011, at 5:03 PM, Jakub Staszak wrote:
> I just found a small bug. Fixed version attached.
>
> <kuba_bp3.patch>
Committed as r132613 (and r132616). Thanks Jakub!
To help reviewers understand the patch and where we're headed with it, I've prepared the following design documentation. For now I'm sending it to llvm-dev until we have an official design doc for