Displaying 20 results from an estimated 23 matches for "jasbur".
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 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 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 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
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 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
2006 Jun 07
2
Redirect if session is nil
How exactly do i redirect a user if they''re not logged in?
I have a cookie being written to the @session variable on login and I
can pull info from it. For instance "@session[''user''].login" pulls their
username just fine. But if they type in the url of the "welcome" page
without logging in I get "You have a nil object when you didn''t
2006 Jun 14
1
Partial matches with find_by
I have a form passing a parameter to a "show_search" action. Everything
goes fine, as long as i search for the exact title of the post. How do I
do a partial or "wild card" search? Code below:
def show_search
@posts = Post.find_all_by_title(params[:title])
end
--
Posted via http://www.ruby-forum.com/.
2006 Jun 27
3
start_form_tag question..
i am trying to get a start_form_tag working, but i am shooting blanks..
here''s what i am trying to do..
i have a controller called "forms.." with an action "new_entry"..
it is called by:
localhost/forms/new_entry
this is just a quick form to test another action..
that action is:
localhost/logger
my question is, how do i construct start form tag in order to
2006 Jun 10
3
Inserting data to another DB table
I have a form under one controller/model called "billing" using the
"bills" table. When this form completes I want it to change the
"has_billing" field for the user under the "users" table from "0" to
"1". I''ve almost got it. I put:
user = User.new
user.update_attribute("has_billing", "1")
under the
2006 Aug 08
1
Paginating an existing array
I have a rather complex query that constructs the array @posts I''d
really like to have these results paginated, but the nature of the query
I''m running won''t let me use pagination the normal way.
Since I already have a complete array, can''t I just paginate those
results some way?
--
Posted via http://www.ruby-forum.com/.
2006 Jul 03
0
Check if row already exists?
I''m working on a system that has a series od "bids" associated with
"posts". Vurrently when a bid is placed I have it creating a new row
each time in the "bids" table. The bids table has id, post_id, and
user_id.
The logic is to check to see if a bid already exists with a given
post_id and user_id. If it does, then just update the "amount"
2006 Jul 10
0
Paypal gem issues Webrick won''t boot :(
I installed the paypal gem and downloaded the plugin as instructed at
http://dist.leetsoft.com/api/paypal/ When the plugin is in the
vendor/plugins folder WEBrick refuses to start. No error messages, just
"=> Booting WEBrick..." then back to my prompt.
Do I have to declare the plugin someplace or something?
--
Posted via http://www.ruby-forum.com/.
2006 Jul 26
0
SQL query syntax
I need to search a specific column with an OR statement from a form, but
can''t quite seem to figure out how. Right now I have:
@query = request.raw_post || request.query_string
@phrase = @query.sub(/ /,"% OR %")
@posts = Post.find(:all,
:conditions => [ ''(title LIKE :search_query OR
body LIKE :search_query OR city LIKE :search_query
2006 Jun 07
0
Using a RegExp to exclude an email address
How would I use a regular expression to eclude an email address? I''m
using validates_format_of :username,
:with =>
:message => "Your username cannot be an email
address."
What is the expression to use after "with: =>" to exclude an "@"?
--
Posted via http://www.ruby-forum.com/.
2006 Jun 15
1
Paginating a .find
how exactly would I apply paginate to a .find I have:
@posts = Post.find(:all,
:conditions => [ ''(title) OR (body) LIKE ?'', ''%''
+ params[:query] + ''%''],
:order => ''end_date'')
How would I go about paginating the uoputed list? Something like 10 on a
page.
--
Posted via
2006 Jun 15
1
Multiple :conditions?
How do I add multiple conditions to a paginated list? I have:
@post_pages, @posts = paginate(:posts,
:per_page => 10,
:conditions => [ ''(title) OR (body)
LIKE ?'', ''%'' + params[:query] + ''%''],
:order =>
2006 Jun 16
0
Comparing form enrty to a databse record
I have one field on a from where a number will be entered called
"amount". I need to compare this to an existing field in the database
also named "amount" to make sure it is a higher number.
I also have to find this specific record by comparing it''s "post_id"
field with @session[:post].id Any help here would be greatly
appreciated.
--
Posted via