similar to: Simple Search

Displaying 20 results from an estimated 6000 matches similar to: "Simple Search"

2006 Feb 13
2
categories and admin/categories - different controllers and templates?
Is there some way to have these two sets of URLs use totally different controllers and templates? categories/list categories/show/1 admin/categories/list admin/categories/edit/1 admin/categories/destroy/1 admin/categories/update/1 Besides, of course, using different controller names ;). The first URL is publicly accessible, while the second contains admin functions. Also, with the second,
2006 Feb 03
9
Because I''m very slow - trying to use console
I can''t see how to use variables so I am using console to test things out... clients table - a column named first_name My very brief console session... >> clients = Client.find_by_sql("select * from clients where first_name = FN") ActiveRecord::StatementInvalid: RuntimeError: ERROR C42703 Mcolumn "fn" does not exist Fparse_expr.c L1034
2006 Jul 10
3
how to access a model from application.rb
Hi All How do I access a model from within the application.rb? What im tying to do is pull some data from a model (news in this case) that must be displayed on each page within the entire application. I know I could drop this into each controller, have each view pull it from the controller, but thats repeating myself... So whats the best way to do this (as I dont think models are visible
2005 Nov 18
2
help with User.find() and rendering text
Hi all, I''m trying to do something for a project. Herez what im trying to do. The user name gets passes from the view to the controller. On line2: The user name gets displayed. On line 3: (If this command works the way I think it works, the sad part is I always get it wrong) anyways, The entry in the data base with the given user name gets searched and the user info gets stored in
2006 Aug 05
5
RESTful Nesting issue
I?m having a strange issue with nested routes though, and was wondering if anyone could shed some light on this? If I have: map.resources :users do |users| users.resources :items end When I try to call <%= link_to_remote ''Delete'', :url => item_url(@item), :with => "''_method=delete''", :confirm => ''Are you sure?''
2006 Jul 23
3
Newbie: Display hierarchical Records in a view
Hi, I have two models: category and subcategory. (one to many relationship), and a controller ''home'' I''d like to display all the categories and their sub categories in the view: home\index.rhtml. I have a method in the ''home'' controller'' like this: def list_categories @categories = Category.find(:all) end This list all the categories
2005 Dec 19
6
custom find methods and pagination
i''ve got several methods in my models i use to find based on certain criteria...i''ve done this so the controller code is less cluttered, plus the DRY factor. example: class Foo < ActiveRecord::Base def find_by_something(something) find :all, :joins => ..., :conditions => ... end def find_by_something_else(something_else) find :all, :joins => ...,
2006 Jul 14
3
compare two tables and find the difference?
I need to compare a column in TableA to a column in TableB and then select 3 columns from TableA for all the records in TableA that don''t exist in TableB. TableA and TableB are different but do have one field in common that i am comparing. The tables are not related in anyway. right now I have a find_by_sql query located in a model that looks like this: def self.absent_charges
2006 Mar 13
7
Wilcard search
Hello, I''m writing a search function for my application, but I am unsure on how to search for all results that contain my search string; here''s what I''ve got: def search @products = Product.find(:all, :conditions => "date_available < now()", :conditions => [ "title ilike ?",
2007 Sep 13
3
Templates and undefined variables
Using puppet 0.23.2, I have a template where I wish to do something like this: <% if defined? some_variable %> .... <% end %> Ideally I''d like to tell these three cases apart: a) defined to a non-empty value b) defined to an empty value c) undefined However case c) causes problems - in templatewrapper.rb::method_missing it causes an error to be thrown. I''ve changed
2011 Feb 07
2
Search HABTM relationship in ActiveRecord
Consider the following scenario: Book has_and_belong_to_many Category. In other words, a category may have a lot of books, and a book can have more than one category. What is the best practice to query all books related to some specified categories. For example, if I have following books "From Java To Ruby" - Category: Java, Ruby "Ruby Programming" - Category: Ruby
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
2006 May 18
8
Concatenated key
Hi all, I started playing a couple days ago with Rails and it find it very interesting. But I''m a bit stuck with making it work with a concatenated primary key. I want to use my own names for the DB fields and I''m using SQL Server 2005. My tables look roughly like this: CREATE TABLE USERS ( USR_ID VARCHAR(25) NOT NULL PRIMARY KEY, USR_PASS VARCHAR(25) ) CREATE TABLE
2006 Apr 21
5
Simple Question: How to merge SQL results?
Hopefully an easy one, how do I merge two or more SQL query results? Example: result1 = find_by_sql(x) result2 = find_by_sql(y) What is the best way to merge result1 and result2? I want to be able to reference the objects as if they were obtained via one query. Cheers, Dan
2005 Oct 28
4
find_by_sql column types
Hello-- There must be a better way to do this. I have a class method in my model that finds averages and does a few calculations using find_by_sql. The problem I¹m encountering is that all computed columns from MySQL come back as type string. E.g., def self.find_averages(domain_id) if @@domain_average return @@domain_average else @@domain_average =
2006 Mar 12
11
HABTM selection conditions
Hi, I am currently trying to learn RoR and there is something I cannot figure out. I have two models: Article and Category, that are HABTM-linked. Everything works fine if I want to select all articles corresponding to a category, with something like @articles = @category.find(@params[:id]).articles However, I have a ''published'' field in my ''articles''
2006 Jun 19
2
fuzzy search
This may be offtopic to Rails, but what are people doing to find records based on fuzzy string matches? For example, if you wanted to find a Person with name "David Heinemeier Hansson" but searched using the string "Dave Hansson". Currently I am find_by_sql that calls the PostgreSQL function "levenshtein(string1, string2)" which returns results with a score
2005 Dec 21
7
use of SET command in find_by_sql
Hi, I''m trying to execute something like this method in a model: def self.sql_for_rankings() sql = "SET @counter:=0;" sql << " SET @counter:=0; SELECT *, @counter:=@counter+1 AS rank FROM testscores. " find_by_sql(sql) end Where the new rank column is a kind of autoincrementer inside of
2006 Feb 09
17
complicated finds are eating my sole
I abandoned ruby way for find_by_sql and still can''t get this... @myplacement = Placement.find_by_sql( "select * from placement where :intake_date >= beg_intake_date and :intake_date <= end_intake_date") just a simple date range...it''s killing me - If I knew how to load placement controller into irb, I could probably try out finds interactive mode... Thanks
2006 Apr 11
5
Reading MySQL rows
Hi there, I?m having difficulties reading the content of some rows in my database. Tried to use some of the code at page 221 in the pickaxe, but didn?t make it work. The SQL query works fine directly against the database. mysql> select id, count, company from users where name = "martin"; +----+-------+------------+ | id | count | company | +----+-------+------------+ | 1 |