Displaying 6 results from an estimated 6 matches for "find_recent".
2006 May 01
2
Find by time?
I''m trying to find events created after an initial date. I''m sure it''s
something obvious, but I''m not sure why this isn''t working:
def self.find_recent
find(:all, :conditions=>"created_at > #{Time.local(2006, 4, 27, 22, 0, 0)}")
end
Time for more caffeine for me...
2006 Apr 12
1
Dynamically updating list
hi every body. i am try to do example of agil books.dynamically updating list of chapter 18.
1)this is my code for controller----
class ListnoajaxController < ApplicationController
def index
@items = Item.find_recent
end
def add_item
item = Item.new(params[:item_body])
render(:partial => "item", :object => item)
end
def item
end
end
2)the code for item class in app/model
class Item < ActiveRecord::Base
attr_reader :body
attr_reader :posted_on
FAKE_DATABASE = []
def initialize(body)
@body = b...
2005 Dec 16
0
Quick ORM question
Quick question on this query:
@item.entries = Entry.find_recent(@td.id, 10) || []
My development log file shows that rails makes 2 calls to database! Is
rails ORM not smart enough to know to not load the lvalue of assignment thus
causing another expensive db call? Below are the stubbed models and a log
snip.
class Entry < ActiveRecord::Base
belongs_to...
2007 Aug 18
12
Test::Unit to RSpec
So I''ve just started working on a rails project which currently has
something like 7500 LOC. All of the tests are written in Test::Unit,
although the test coverage is pretty poor: rcov says that 25% of the
code is covered, while rake stats shows the code to test ratio as
1:0.1 (800 lines of test code).
I guess I''m wondering what would generally be advisable here. Is it
2006 Aug 18
1
Fragment Caching
Hello.
I wouldn''t mind getting some feedback about the use of fragment
caching. I''ve got a series of relatively expensive database queries
with their respective partials cached and everything is working fine.
The problem is that do get this to work I''ve had to move the database
queries from the controller into the view layer so as to avoid them
being called if the
2006 Dec 20
4
undefined method `fullname' for #<User:0x357e380>, BUT works on first view?
...you have all the
information....
I have a NewsModel that looks like this:
class News < ActiveRecord::Base
belongs_to :user
validates_associated :user
validates_length_of :title, :description, :minimum => 5, :allow_nil
=> false
acts_as_commentable
acts_as_taggable
def self.find_recent
News.find(:all, :order => ''created_at'', :limit => 10).reverse
end
end
and a controller like this:
class NewsController < ApplicationController
def show
begin
@news = News.find(params[:id])
rescue ActiveRecord::RecordNotFound
flash[:notice] =...