Displaying 20 results from an estimated 286 matches for "find_all".
2006 Jul 09
8
find_all order question
How does one properly get find_all to grab the data from the DB table
ordered by a specific column?
For example:
@anglers = Angler.find_all
This code gets all the angler records and they are sorted in order of
the id field which is of course set as a primary key in the DB (mysql).
I''d really like to pull the data from...
2006 Jan 26
3
global objects?
Forgive the term global if that''s not applicable in rails (i come from a
php background)
I have a browse controller with a couple of different methods
def method1
@properties = Property.find_all
#other stuff for that method
end
def method2
@properties = Property.find_all
#other stuff for that method
end
def method3
@properties = Property.find_all
#other stuff for that method
end
I know RoR is all about not repeating yourself if you don''t have to. Is
there a way to say @propert...
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 se...
2005 Oct 24
3
bogus find_all in Rails 0.14.1
I have the following statement
cl = ChatEvent.find_all("ev_type <> #{t} and chat_id = #{@params
[:chat_id]} order by created_at")
which produces the following error:
#42000You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ''order by create...
2008 Apr 23
0
self referential (n-n relationship) belongs many controller
...reated (or badly : task_id is ok, but
tasklink_id is KO)
Here is my tasks_controller :
-------------------------------------------------------------------------------------
class TasksController < ApplicationController
helper :sorting
def index
list
@statuts=Statut.find_all
render :action => ''list''
end
# GETs should be safe (see
http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
@task_pages, @tasks = p...
2006 Feb 15
3
accepting and passing args to find
I have a method that I want to accept args like the "find" method does
and I need to pass those args along to a find call.
# in controller action:
@projects = Project.find_allowed(session[:user], :order => "name")
# start of the model method:
def self.find_allowed(owner, *args)
projects = self.find_all(args)
...
No matter how I try to pass those args along I get something like the
following error:
ActiveRecord::StatementInvalid: Mysql::Error: #42S22...
2006 Jan 12
17
Application.rb params
I need to check if a parameter is set so that I can build some information
for my application, but No matter how I format my if statement in the file "
Application.rb" it return the following error.
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
Here is the line
if params[:day]
So we
2006 May 11
3
undefined??
...y) encountered the first complication.
After doing those basic actions to set up the basic site, the tutorial
tells me to overwrite the "list" method included in the "scaffold
:recipe" method which we find in the recipe controller with this code:
def list
@recipes = recipe.find_all
end
Now this code doesn''t work. When trying to view my site I keep getting
an error message which says that the variable recipe is undefined.
With the (average) knowledge I own concerning programming I suppose
"@recipes" should define the variable, which doesn''t happe...
2006 Jun 22
11
Help please
...y_id) %></td>
<td><%= (position.city) %></td>
<td><%= (position.state.name) %></td>
<td><%= (position.entered_on_date) %></td>
</tr>
Here is the method in the controller:
def positionslist
@positions = (Position.find_all)
end
The model:
class Position < ActiveRecord::Base
belongs_to :category
belongs_to :contactmethod
belongs_to :edureq
belongs_to :expreq
belongs_to :postlength
belongs_to :securityclear
belongs_to :state
def self.find_all
find(:all)...
2006 Apr 06
6
select method
The documentation states as an example:
select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id ] },
{ :include_blank => true }) could become:
<select name="post[person_id]">
<option></option>
<option value="1" selected="selected">David</option>
<option value="2">Sam</opt...
2006 Jan 24
4
How to filter an activerecord find_all...
...I have a report which is based on units, but i want to be able to filter
the units by which subgroup, or which group, or which division. I also
want to sort them by division.name,then group.name, then subgroup.name.
What''s the syntax i need? I''ve got this far...
@units = Unit.find_all :include => XXX, :order => XXX
Oh, and another topic - i finally figured out how to deploy rails with
lighttpd and scgi on a windows server the other day!
--
Posted via http://www.ruby-forum.com/.
2006 Feb 20
5
find(:all) vs find_all
...was the
ActiveRecord::find() method. I call that sort of API a kitchen sink
method because it does so many different things. It really should be
multiple methods. And in fact, it used to be!
Look in ActiveRecord''s deprecated_finders.rb file. There are three
methods in there - find_all, find_first, and find_on_conditions.
While I can see an argument for dropping find_on_conditions, the
other two seem quite natural, and far preferable to find(:all) and
find(:first). Seems like it would simplify things, including the
documentation for under what circumstances find() retur...
2006 Aug 14
1
Overide the default find_all
Hi,
In my model i want to overide the default find all for sorting purposes.
Is this possible or can this only be done in the control or by adding a
custom method in the model.
def self.find_all()
@contents = Content.find(:all,
:order => ''pos, position_id'')
end
--
Posted via http://www.ruby-forum.com/.
2006 Aug 14
2
finders et sous-classes
...fier de "virtuelle"
end
class IllustrationInterne < Illustration
...
end
class IllustrationExterne < Illustration
...
end
Tout cela fonctionne ? merveille (h?ritage ? table unique), seul hic,
lorsque je d?cide de rechercher l''ensemble de mes illustrations
(Illustration.find_all) j''observe d''?tranges ph?nom?nes paranormaux:
script/console
Loading development environment.
>> Illustration.find_all
=> []
>> Attachement.find_all
=> [#<Document:0x2699c1c @attributes={"role"=>nil, "type"=>"Document",...
2008 Mar 04
6
find_all_by deprecated?
Is find_all_by deprecated and/or find_first_by for 2.0.2? If not,
what is actually deprecated? just find_all(..) and find_first()?
Thanks for clearing this up.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails:...
2006 Jan 19
6
One Last Question for me..
...ng the category name.
What is the easiest way to change that so it redirects back to say
/category/list ?
i know that:
def show
redirect_to :action => ''list''
end
will work, but that will kill my current "show" (for category controller):
@categories = Category.find_all
@recipes = Recipe.find_all
@c = @params[''c'']
@r = @params[''r'']
@recipe = Recipe.find(@params["r"])
is there some way to accomplish this with an if/else statement?
I''ve googled high and low.. I can''t seem to fi...
2005 Sep 25
7
(newbie) Missing Template Error using Rolling With Rails Tutorials
Hi all,
New to the list, Ruby, & RoR. I''ve been going through the Rolling
With Rails tutorial, but am getting the following error when the
instructions tell you to add the @recipes = Recipe.find_all line to
the RecipeController:
Template is missing
Missing template ./script/../config/..//app/views//recipe/index.rhtml
The index.rhtml file is right where it''s supposed to be, and the code
is correct (as far as I can tell, I even used the downloadable version
of the script with the sa...
2006 Mar 17
2
Temporary Model Data
I am trying to optimize some methods in my model so they don''t repeat
CPU intensive algorithms every time I call the method in the same
request/response cycle.
Eg.
================
def invitations
all_pgm_updates.find_all do |update|
update.invited?
end
end
================
I want to do something like:
================
def invitations
if @invitations.nil?
@invitations = all_pgm_updates.find_all do |update|
update.invited?
end
end
@invitations
end
==============...
2006 Mar 22
0
Wierd hash being returned from a .find_all call (usingmySQL)
I was following a basic todo list tutorial, and when I call a:
@items = Listing.find_all
render_text @items.inspect
The following is displayed in my browser, and clues?...
[#"Don", "category"=>"Human", "id"=>"1", "hidden"=>"0"}>, #"Cheese",
"category"=>"Food", "i...
2005 Mar 07
0
an escape from using find_all
Hi,
I''ve got a form where I change and update the @cost values, I wanted
to see a select tag showing all the clients names instead of inserting
manually the code in the textbox... to do so I''ve used
options_from_collection_for_select on another var @client (setted to
find_all on the controller calling this viewer).
<select name="client">
<%=options_from_collection_for_select(@clientList,"id","name",@cost.client_id)
%>
</select><br>
doing this way on the controller I have @cost and @client, and I must
set...