Displaying 20 results from an estimated 1600 matches similar to: "Advanced search/filter use cases"
2007 Apr 19
5
Best practice thoughts: Model helpers, mocks
Hello! I''m pretty new to unit testing, and have only been using RSpec
for a few weeks. I found that for my controller specs, my setup
methods were getting very long building mocks/stubs for all the model
objects I needed to work with.
I''ve started creating helpers like the following for each of my
models. The "min_" methods are short for "minimum", and
2005 Dec 20
7
wrong id for activerecord object when using :joins in mysql
I''m using a find with a :joins clause, like this:
:joins => "JOIN table_b ON table_b.id=table_b_id"
The records returned are used in a scaffold generated list page. The edit,
show, and destroy links are getting the wrong id. They are getting the id of
the table b record.
When I run the query using mysql, I see that the query returns *2* id
columns, the id of the main
2006 Mar 01
5
validations without AR - going crazy trying to find link
Hi,
in the past few months someone posted an entry on their blog about
how to do validations in non-AR classes and I cant find it any more.
Anyone have a link?
Thanks,
Trevor
--
Trevor Squires
http://somethinglearned.com
2006 Jan 19
8
Pagination_links without "?page=" but with params[:id]
Hello,
With default pagination I have this :
<a href="/users/infos/3?page=1">1</a>
<a href="/users/infos/3?page=3">3</a>
but i need this :
<a href="/users/infos/1">1</a>
<a href="/users/infos/3">3</a>
I need to remove the "?page=" parameters and rewrite a little the link ( with a link_to ? )
2005 Dec 16
4
Validation with Aggregation
ActiveRecord supports composed_of for value objects which is
fantastic but one thing that it doesn''t seem to support (or at least
I am unable to find any documentation for) validation of the value
objects.
For example, given the following:
class Message < ActiveRecord::Base
composed_of :sender, :class_name => ''EmailAddress''
composed_of :recipient,
2006 Mar 20
2
Rails Plugin to Help Debug Views
Hi,
I just released a plugin to help debug views. The plugin makes it easy
to add a button that will popup a new window that displays the
following debug data;
* Request Parameters
* Session Variables
* Flash Variables
* Assigned Template Variables
It was derived from code that traces back to Marten Veldthuis in
Epilog. You can check out webpage and plugin via;
2006 Jan 30
3
ActiveRecord without database
The question is this.
Can I use ActiveRecord without the presence of a database?
I use only YAML file for my project and I would like use the power of
ActiveRecord for my models. I have not tested and so I ask you if this
is possible.
Thanks so much.
--Reis
--
Posted via http://www.ruby-forum.com/.
2006 Jun 25
3
Dummy field in a model
I want to have a field in model, which I''m not storing in a database.
And I want to do something like the following in the model code :
validates_format_of :field_NOT_in_db, :with => session[:field]
How can I do it ?
Thanks,
Pratik
--
rm -rf / 2>/dev/null - http://null.in
2006 Aug 16
5
too many SESSIONS?
I just notices my app was down, and in the log file were lots of these:
No space left on device -
../config/../tmp/sessions//ruby_sess.898b1cf95e14f8e3
So i figured that i had too many sessions. I went through and deleted
the sessions and then in a few minutes, the site was back up again.
Can anyone explain this?
Did I do the right thing?
Is there a way I can tell my app to accept more
2005 Dec 23
6
Agile book - test error
Hi all,
I get an error when testing the "store_controller_test.rb"
The troublesome line is in the test below:
def test_add_to_cart
get :add_to_cart, :id => @version_control_book.id <<<
cart = session[:cart]
assert_equal @version_control_book.price, cart.total_price
assert_redirected_to :action => ''display_cart''
follow_redirect
2006 Aug 07
4
Problem with Pagination
Hi Guys,
I am trying to paginate the results from a search. When I use actual
constants in the search conditions, it works fine:
def query
@k2_result_pages, @k2_results = paginate (:k2_results,
:conditions => [''e_date >= ? AND
e_date <= ?'', ''2006-07-12'', ''2006-08-12''],
2006 Jul 17
2
IndexedSearchEngine Question
Good evening --
I''m really new to Rails and I was looking for a way to use
IndexedSearchEngine with a "get" call instead of the default "post". I
have the script by itself on a page /myapp/app/view/search/rhtml and I
want to be able to bookmark the query string.
I can''t seem to find where in the code the call to form_tag is. This is
as likely as not a
2006 Jan 19
2
Easy way to handle form input without a model class?
I have a couple forms that I''d like to be able to validate and
automatically populate, but it shouldn''t be based on AR. In fact I
often have a bunch of small forms that I can''t really justify writing
a whole new model class for anyway. I''d like to validate the form
input, and then use rails helpers to automatically populate the form
if validations fail.
2006 Apr 27
2
How to override pagination_links method
I intend to override pagination_links method.
I added following lines of code in application_helper.rb
module ActionView
module Helpers
def pagination_links(paginator, options={}, html_options={})
raise("boom!!")
end
end
end
But my code is not executing my code. The view is still using the method
pagination_links from rails.
What''s the correct way to override
2005 Dec 21
13
Too many login generators?
there is a blog about it
http://www.realityforge.org/articles/2005/11/12/aaa_in_rails
There are so many Authentication/Authorization/Auditing generators now,
just like the situation in java''s world, Too many components doing the
samething just make me confusion. Why not add one to rails core lib and
everybody can extend it for their requirement ?
--
Posted via
2006 Apr 10
0
Rails form error message oddness...
To get error messages for my form to show up I have to repeat myself in
the controller so that the render of the view including error messages
show up.
-------------------------
My Controller:
-------------------------
class ClientsController < ApplicationController
#---- index --------------------------------
def index
list
render :action => ''list''
end
2006 Jul 23
2
pagination_links and friendly urls
my pagination_links seems to auto generate the links using the current
controller, action and id. The page they''re appearing on however have a
friendly url I have created. I want to be able to make pagination urls
generated by pagination_links "user friendly" as well so that they match
my current naming convention.....i know there must be a way to do
this....any ideas?
2006 May 14
3
Beginner question on paginate with params and conditions
I am trying to do a simple search by product name. The first page
returns fine, but when I try to go to any other pages of the search
results, I lose the original search parameters from my search form and
get NilClass errors.
Here is the code in my controller:
namesearch = "%" + params[:name].strip + "%"
@product_pages, @products = paginate :product,
2012 Feb 21
10
Search of multiple columns
I am currently writing a search method for my rails applications and at
the moment it works fine. I have the following in my game.rb:
def self.search(search)
if search
find(:all, :conditions => [''game_name LIKE ? OR genre LIKE ? OR
console LIKE ?'', "%#{search}%", "#{search}", "#{search}"])
else
find(:all)
end
end
No that searches
2006 Mar 02
1
Forms with and without Models and Error Handling
Hi,
I currently programming a delicious clone to understand ruby on rails.
The problem I''ve got is that I prefill a form (form without models)
without a database connection and then save it into the database.
For validation i am using the validation helper methods. My Problem is
that i don''t know how I get the error hash from the helper method
validates... etc. because I