Displaying 20 results from an estimated 9000 matches similar to: "Partial matches with find_by"
2006 Jun 13
9
Find DB items by "title"
I''m having trouble finding then displaying all items in my "posts" table
that match a certain search string.
I have a from field:
<%= start_form_tag :action=> "search" %>
<div title="Search" id="searchform" class="form">
<h3>Search</h3>
<%= error_messages_for ''post''
2006 Jun 12
5
Doing a simple search from the database?
I realize thi may be more complex issue than can be asnwered in this
post. But, what I need to do is create a simple query on my existing
tables via a search form. I have half my app done (I can write all the
info I want to my database), but pulling the data out dynamically is
giving me trouble.
I have both the "ruby for rails" book and the Agile Development book.
They both give
2006 Jun 25
1
Using AND in :conditions queries
I have what amounts to a simple search engine running through a table
using input from a form. Everything works fine when looking for "title"
or "body" But, when I want to couple that with an AND statement the
search still works fine, but it seems to disregard the AND statements.
Code below:
In the view:
<%= start_form_tag :action=> "show_search" %>
2006 Feb 15
3
Like Query Across Multiple Tables
Firstly, I''m still learning Ruby and rails, so there could be a very
simple solution to this.
I want to search across multiple tables with a "like" query eg: (SQL is
probably the easiest way to describe it):
select
products.*
from products
inner join brands on products.brand_id = brands.id
where
products.name like ''%canon%''
or brands.name like
2006 Apr 15
8
Inheritance in Rails - I need some help
I''ve got a model, "category" and another model "subcategory." Each
subcategory belongs_to a category, and a category has_many
subcategories.
What I need to do is set it up so that I can search Category and
Subcategory with one .find call. So:
Category.find(:all, <etc)
will find categories and subcategories.
Now, I believe this can be done by making
2006 Jan 03
1
find_by datetime question
Hi,
I was wondering if any of you Rails/SQL ninjas knew of an elegant way
to grab from activerecord all the rows that are within an interval of the
current time (say in the last week). For instance, if there''s the
created_on datetime column, is there a zippy way to use find() without SQL?
It seems like the Ruby
DateTime object doesn''t really do intervals for numerous
2006 Jan 07
1
Difference in find_by
Hi all,
Been digging to a lot of ruby docs to understand more of what Rails is exactly
doing. Can somebody tel me what the difference in use is between the
"@params" and "params". (I know the first is a instance variable and the
second is a ''normal'' variable. What does this mean in pratical terms?
@contact =
2010 Nov 28
2
Dynamic find_by method returning nil in a class method
I have a user Model with a class method that I am using to do some
authentication
basically something like this
class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :first_name, :last_name,
:email, :birth_date, :sex,
:password, :password_confirmation
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :first_name,
2006 Jun 14
4
Using now() to determine what should be displayed
I''m trying to create a paginated list that will take note of the
"end_date" field in my table. This is what I have:
@post_pages, @posts = paginate(:posts, :per_page => 10, :order_by =>
''end_date'')
in the controller. And for the view:
<h1>Posts ending soon</h1>
<ul><% for post in @posts do %>
<strong>Post Title:
2006 Jan 31
2
Relationship navigation issue
class Event < ActiveRecord::Base
belongs_to :venue
belongs_to :category
end
class Venue < ActiveRecord::Base
belongs_to :city
end
class City < ActiveRecord::Base
belongs_to :state
end
I want to retrieve all event records belonging to a state. Coming from
hibernate background I tried something like this:
def self.list_for_a_state(state_id)
find_by_sql(["select e.*
2006 Apr 20
7
Rails + postgres case insensitive searches.
Hello all
I am wondering how rails handles case sensitivity in databases. If I
do a Person.find_all_by_name("tim") in mysql I would expect to get
tim, TIm, and Tim. Do I only get tim in postgres?
How do other people deal with this? Do you resort to find_by_sql for
all your postgres queries to get case insensitive results?
2006 Jun 18
3
Ambiguous clause error
I''m trying to query one table to ultimately display the relate info from
another table. I have 2 tables: "posts" and "numbers". I''m trying to do
a query like this:
@numbers = Number.find(:all,
:conditions => [ ''(user_id) = :id'',
{:id =>
2006 Apr 11
2
Finding items from two models - then merging them
I have a model, listings. Listings habtm categories and subcategories,
which are seperate models.
What I want to do is search categories for certain items, like so:
@categories = Category.find(:all, :conditions => ["name LIKE ?",
"#%{:search_string}%"
and subcategories for the same:
@subcategories = Subcategory.find(:all, :conditions => ["name LIKE ?",
2006 Jun 08
3
Foreign key confusion
I have 2 models right now: "users" and "posts". When a user creates a
post I would like their id to be recorded under "user_id" in the "posts"
table. Under the "user" model I have:
class User < ActiveRecord::Base
has_many :posts
end
And under the "posts" model I have:
class Post < ActiveRecord::Base
belongs_to :user
2007 May 24
4
design patterns
Hi everyone
I''m Maximiliano Guzenski from Brazil and I am programing on ruby on rails
only a couple of months.
I read a lot of books and articles about it but I could not clarify some
doubts about design patterns:
1) Is it really good put some sql command on controller? because all
articles that I see use sql into controllers, like:
# my controller
@categories = Category.find
2017 Aug 30
3
Status of reverted Linux patch "tty: Fix ldisc crash on reopened tty", Linux 4.9 kernel frequent crashes
Hello everyone,
Recently Nathan March reported on centos-virt list he's getting frequent Linux kernel crashes with Linux 4.9 LTS kernel because of the missing patch "tty: Fix ldisc crash on reopened tty".
The patch was already merged upstream here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=71472fa9c52b1da27663c275d416d8654b905f05
but then
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 May 01
12
pagination in acts_as_ferret
I''m just wondering where I would put the pagination for search results
when using "acts_as_ferret".
At the moment my search code is..
def search
@query = params[:query] || ''''
unless @query.blank?
@results = Tutorial.find_by_contents @query
end
end
Cheers
SchmakO
--
Posted via http://www.ruby-forum.com/.
2006 Jun 25
1
Sorting ferret results by column
I have the acts_as_ferret plugin installed. Everything searches great,
but I would like to limit the results (i.e. by ''end_date'') and sort them
(by ''end_date''). ''end_date'' is a valid column in my "posts" table.
Here''s the code I have already:
@posts = Post.find_by_contents(params[:query])
params[:query] comes from a form. I
2006 Jun 27
4
File Column has me stumped
I have an existing entry in my DB under the "users" table that has a
column name "pic". I have a file column field when a new user signs up,
and it work great. I am now trying to give existing users the ability to
add or change their "pic". But, no matter what I do the entry comes up
blank. Here''s what I have so far:
View:
<%= start_form_tag ({:action