Displaying 20 results from an estimated 10000 matches similar to: "Is it possible to query on virtual attributes?"
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 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,
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 -
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
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,
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 07
3
wrong number of bind variables
I''m getting this error message since i moved alot of the database
logic to the model.
wrong number of bind variables (0 for 2) in: first_name = ? AND last_name = ?
def self.authenticate(first_name, last_name, password)
user = User.find(:first, :conditions => [''first_name = ? AND
last_name = ?''])
if user.blank?
Digest::SHA256.hexdigest(password +
2006 Aug 07
2
Bind variables error
wrong number of bind variables (0 for 2) in: first_name = ? AND last_name = ?
I''m not sure why I"m getting this error ?
def self.authenticate(first_name, last_name, password)
user = User.find(:first, :conditions => [''first_name = ? AND
last_name = ?''])
if user.blank?
Digest::SHA256.hexdigest(password + user.password_salt) !=
user.password_hash
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
2007 Aug 26
2
Multi-word query searching across columns
I''m trying to implement a basic name search on a People table with
separate first_name and last_name columns. I am using the
will_paginate plugin and have the following search method in the
model:
def self.search(search, page)
paginate :page => page,
:conditions => ["lower(last_name) like ? or
lower(first_name) like ?",
2007 May 30
4
aaf and dynamic attrs: a bug?
Hi!
I faced some issue while using it for dynamic attrs indexing/search.
Maybe I made something wrong. Here is test method. Everything works just
fine until last line http://pastie.caboo.se/66274 . Tested on both
stable and trunk of aaf and ferret 0.11.4.
the short version of code below:
Contact.acts_as_ferret :fields => [ :first_name ]
assert
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in
the browser.
<h1>New member</h1>
<%= error_messages_for :member %>
<% form_for(:member, :url => members_path) do |f| %>
<fieldset>
<legend>Member Info</legend>
<p><label for="member[first_name]">First Name:</label> <%=
2005 Feb 05
4
Creating collections
I''m trying to create a form where a collection is created, using the
example from the Rails 0.9.5 weblog posting:
http://weblog.rubyonrails.com/archives/2005/01/26/rails-095-a-world-of-
fixes-and-tweaks/
I''m having a bit of trouble. The controller currently looks like this:
class StudentController < ApplicationController
def new
render_text @params.inspect
2006 Mar 20
2
AHHHhhhhh... has_and_belongs_to_many, that is going on?
I don''t have a class by the name of "ReviewersScoreCard", yet my many to
many configuration looks as follows. And, these errors while running some
simple test with ./script/console is giving me a headache:
./script/console
Loading development environment.
>> r = Reviewer.find_first
=> #<Reviewer:0x19d0a48 @attributes={"id"=>"1",
2006 Feb 26
3
simplify
Trying to use Eric''s help and Amy Hoy''s page of playing with
auto_complete and decided that the script/console is the place to
rapidly test.
I have this feeling that CONCAT isn''t working for postgresql...
c = find_by_sql(SELECT * FROM clients WHERE CONCAT
(first_name,middle_initial,last_name) = "johnadams")
^
(irb):61:
2006 Apr 30
16
postgresql duplicate key violates unique constraint
I have a weird problem with creating a new record when using PostgreSQL.
From inside script/console ...
>> entity = Entity.new
>> entity.first_name = "Foo"
>> entity.last_name = "bar"
>> entity.save
Throws an exception due to the following SQL error: duplicate key
violates unique constraint.
The application was working fine before and suddenly
2012 May 21
4
Getting model column names
Hello,
I am writing a RoR application that connects to a couchDB database using
couchrest_model.
The definition of my model is the following one:
class BdsDataAuthor < CouchRest::Model::Base
property :id, Integer
property :first_name, String
property :last_name, String
end
I would like to be able to get the list of the model columns, e.g., the
result of
BdsDataAuthor.columns would be
2010 Jun 05
6
How do you update HABTM relationships or create.
Hi,
I have a User model with a HABTM relation to a Role model and vice
versa. So There''s a roles_users table that references :user and :role.
I''m using formtastic, and in the user.edit.html.erb I have a line that
outputs the roles as a multi-select list box. But the box is not
showing the roles that have been assigned to the users.
Another problem is that if I select a few
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