Displaying 20 results from an estimated 20000 matches similar to: "active record aggregation"
2006 Jul 22
3
refactoring commonly used aggregations
I have a number of models that use an aggregation to combine First Name,
Middle Initial and Last Name and they have been working fine. I am
looking to clean this up, DRY it if possible.
I have things like this in application.rb
class Clwholename
attr_reader :first_name, :middle_initial, :last_name
def initialize(first_name, middle_initial, last_name)
@first_name = first_name
2006 Aug 11
0
SQL sort
in my list action, I setup the sort parameters as folows :
..
sort = case @params[''sort'']
when "login" then "login DESC"
when "first_name" then "first_name DESC"
when "last_name" then "last_name DESC"
end
...
to be used in a ''sort_link_helper''
2010 Oct 05
2
Is it possible to query on virtual attributes?
I have a Person model with attributes first_name and last_name.
I want to implement autocomplete search that looks that the entire
name. Hence I have a method:
def full_name
self.first_name + " " + self.last_name
end
Is it possible for me to query on full_name and have rails match the
first_name and last_name fields?
I currently receive this error when I try, because full_name
2006 Jan 19
2
Simple Ferret Questions
I am trying to use Ferret for searching for users based on first and last name.
In my index, I am adding the first_name, last_name, and a full_name
which is basically "#{first_name} #{last_name}".
I am searching the index using something like the following query:
INDEX.search_each(%Q/first_name:#{query}* OR last_name:#{query}* OR
full_name:#{query}*/) do |doc, score|
The problem I am
2006 Mar 16
6
How to have multiple fields appear in collection_select?
I have a table of employees with the fields "last_name" and
"first_name". I would like to populate a collection select so that what
the user sees in the drop-down is "Last Name, First Name". So far, the
only way I have figured out to do this is by using "find_by_sql" in my
model, like so:
@employees.find_by_sql("SELECT id, concat(last_name,
2005 Mar 08
1
Adding to model (newbie)
Sorry if this is a really lame question, I''m sure it''s something fairly
obvious, but I just can''t see it at the moment...
I''m trying to add something simple to the model for a project
management/todo list/thing. The DB has ''first_name'' and ''last_name'',
and I''d like to have "full_name" available.
So -
2006 Feb 27
2
Ajax - from there to here
Trying to use Amy Hoy''s ajaxariffic auto_complete methodology and I am
getting really close to the end.
This is fairly complicated but I will simplify as best I can.
My view code is simple...
<%= text_field_with_auto_complete ''client'', ''wholename'' %>
# wholename is not a column in ''clients'' but rather represents an
2006 Jul 14
1
creating a computed column with activerecord for to_xml
Hi. I have a question about activerecord, computed columns and to_xml.
I have a simple model called person that has a first_name and a
last_name field (and thus a first_name and last_name field in the Person
table). When I :find a model and call to_xml, I would like the result
to not only send back first name and last name as xml but also add an
additional attribute called full_name that is
2006 Mar 04
6
validation of aggregates
This may not be possible...
I have an aggregation of clwholename defined in my model.
the aggregation builds clwholename from :first_name, middle_initial,
last_name
and it generally works fine.
I am trying to add a validation so while there may be many ''John''
first_names, and ''Doe'' last_names, I only want one ''John Doe''
so I tried...
2009 Sep 08
1
How to validate_uniqueness_of the joint of two attributes?
Hi,
I have a form that asks users to put in their :first_name and :last_name.
How do I validate that their full_name (first_name + last_name) is unique?
Thanks!
Nguyen Anh Hung
Assistant Project Manager/ Consultant/ Business Analyst
Tech Propulsion Labs
Mobile: +84987 005 477
Twitter: http://www.twitter.com/anhhung
Blog: http://www.fresco20.com
Skype: anhhung.n | Yahoo: hero.tuxer | Gtalk:
2006 Jan 25
7
join fields for list views
I am sitting with the Agile book on my desk and scratching my head at
the discussion on aggregation - perhaps that isn''t what I need.
I have a db called clients.
fields include - first_name middle_initial last_name
I want to combine them all into one name element in a list view. I can
add/edit the fields separately but in the list view, I only want the one
combo field.
Is there a
2007 Nov 28
5
methods in models dont work for views?
This question is more towards understanding how things work rather than
trying to just get something to work.
I have something like this in my user model.
def full_name
first_name + " " + last_name
end
This works find if I use it for display values in a
collection_for_select.
options_from_collection_for_select( @users, :id, :full_name)
It displays the full name in the
2006 Jan 20
4
Questions about Searching
Hi,
I have some questions about searching with Ferret. I have a user
index with first_name, last_name and full_name (which is just first
plus last with a space).
Here are a couple of questions:
1) If I store the fields tokenized, it appears as though queries are
case-insensitive. However, for untokenized, the query is
case-sensitive. How can I make the untokenized searches
case-insensitive?
2006 Jul 30
2
options_from_collection_for_select & multiple columns
I have a table with first_name and last_name, and wan''t to populate a
drop-down with the id and the person''s name consisting of the first and
last names concatenated together.
Can''t figure out how to tell options_from_collection_for_select to do
that.
Any ideas?
I basically need to do something like:
<%= options_from_collection_for_select @media_creators,
2012 Jan 06
1
How to pass a field from simple_form as a hidden div value
Hi folks
Im trying to pass a value to my hidden div using simple_form but im
not sure how to do this, was wondering if anyone could help me with
this. Here is my view using simple_form
<%= f.label "First name" %>
<%= f.text_field :first_name %>
<%= f.label "Last name" %>
<%= f.text_field :last_name %>
<%= f.input :full_name, :as =>
2010 May 05
0
Auto_complete with has_one association
Hi,
Have an issue with the rails auto complete, it works fine but I don''t
know how to find the id element search in the textfield.
Here is what I''ve done:
<%= text_field_with_auto_complete :user, :ville_name, { :size => 15 },
{ :url => formatted_villes_path(:js), :method => :get, :param_name =>
''search'' } %>
Model:
class User <
2009 Apr 25
0
'get_user_list' function not working
i want to show fullname by using fuction call ''get_user_list'' , but
its not working..??
tis s user.rb
(
def full_name
self.first_name + " " + self.last_name
end )
my post controller
( def get_user_list
return User.find(:all, :order => ''last_name ASC'').collect {|user|
[user.full_name, user.id]}
NameError in
2006 Jun 22
0
Active record associations
I have a table containing a person''s info:
Person
{
first_name : string
last_name : string
height : int
weight : int
age : int
}
This person can belong to many leagues and 0 or 1 teams within that
league. I can create join tables and use the following associations:
League has_and_belongs_to_many people
Team has_and_belongs_to_many people
League has one
2006 Feb 26
2
auto_complete on steroids
I am trying to get more out of auto_complete than it apparently was
designed to deliver.
My problems seem to be two fold.
1 - I use aggregations on
names... :first_name, :middle_initial, :last_name and then aggregate
them using a composed_of :wholename thing
auto_complete_for seems to be wired to only use table columns directly
and gags on the aggregate form.
2 - foreign table columns -
2006 May 17
5
text_field_with_auto_complete (newbie question)
I have the text_field_with_auto_complete woking on my user DB using
last_name. so looking for ''ivanoff'' works great, but I can''t find
''john''. Plus I like to have ''last_name, first_name'' show up in the
dropdown.
what I can''t figure out is how to concat first_name and last_name to
make a name and use that to look it.
working