Displaying 4 results from an estimated 4 matches for "posted_on".
Did you mean:
post_on
2009 Jul 23
11
Problem with named_scope
Here are my scopes:
default_scope :order => ''posted_on DESC'', :conditions => { :status =>
''visible'' }
named_scope :positive, :conditions => { :rating => ''positive'', :status
=> ''visible'' }
named_scope :neutral, :conditions => { :rating => ''neutral'',...
2006 Apr 12
1
Dynamically updating list
...; 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 = body
@posted_on = Time.now
FAKE_DATABASE.unshift(self)
end
def self.find_recent
FAKE_DATABASE
end
# Populate initial items
new("Feed cat")
new("Wash car")
new("Sell start-up to Google")
end
3)now i make two template
1)ind...
2007 Apr 21
3
attachment_fu thumbnails
...cord::Base
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 1.megabyte,
:thumbnails => { :thumb => ''164x164>'' }
end
create_table :photos do |t|
t.column :filename, :string
t.column :posted_on, :datetime
t.column :description, :text
t.column :name, :string
end
def create
@photo = Photo.new(params[:photo])
if @photo.save
redirect_to :action => ''list''
else
render :action => ''new''
end
end
--
Posted via http://www.ruby-forum.co...
2006 Apr 02
7
RANT: belongs_to -> refers_to
...adding
class Item < ActiveRecord::Base
:has_one primary_picture, :class_name => ''Picture''
end
I am encouraged in this futile pursuit by the docs, which I quickly skim to
see things like
:has_one :last_comment, :class_name => "Comment", :order => "posted_on"
Of course, in the light of day, it''s clear that this automagically creates
the last_comment association by picking the most recent comment. But at
3am, it just reinforced the tendency to use has_one. Ditto the many other
has_one examples I found - half of which used the automatic-...