Forum: Ruby on Rails Typo 1055 created_at Vs. published_at

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ed G. (Guest)
on 2006-05-27 15:01
[Couldn't post this to the Typo forum, hope it's Ok here :-)]

Before I go off and create a Typo ticket, I'd like to know if anyone
else is experiencing this and what there thoughts might be on the
subject?

In Typo 1055, if you use the admin interface and change the published
date for an article, you will get "post not found", when you click on
the article in the user interface.

I belive that the user interface should use the published_at date,
instead of the created_at date.  The admin interface only allows changes
to the published_at date.  Using the published_at date in the user
interface gives you more control over your blog and how the articles are
presented.

Here are my suggestions:

app/models/blog.rb
line 140
def article_url(article, only_path = true, anchor = nil)
		# Changed from created_at to published_at - Ed Gard 5/27/06
    #url_for(:year => article.created_at.year,
    #        :month => sprintf("%.2d", article.created_at.month),
    #        :day => sprintf("%.2d", article.created_at.day),
    #        :title => article.permalink, :anchor => anchor,
    #        :only_path => only_path)
		url_for(:year => article.published_at.year,
            :month => sprintf("%.2d", article.published_at.month),
            :day => sprintf("%.2d", article.published_at.day),
            :title => article.permalink, :anchor => anchor,
            :only_path => only_path)
  end

The above fixes the "post not found" when a published_at date is changed
in the admin interface.

app/controllers/articles_contoller.rb
line 19
def index
    @pages, @articles =
      paginate(:article, :per_page => this_blog.limit_article_display,
               :conditions =>
                 ['published = ? AND contents.created_at < ? AND blog_id
= ?',
                             true,            Time.now,
this_blog.id],
               #:order_by => "contents.created_at DESC",  - Changed to
published_at by Ed Gard 5/27/06
							 :order_by => "contents.published_at DESC",
               :include => [:categories, :tags])
  end

The above lets the admin changed the display of the blog ordered by the
published_at date, not the created_at date.

Ed
This topic is locked and can not be replied to.