Reputation: 12650
I'm getting a SQL error with this:
Model:
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :entry
attr_accessible :body
validates :user_id, :presence => true
validates :entry_id, :presence => true
validates :body, :presence => true, :length => {:minimum => 10, :maximum => 5000} #spam/stupid protection
default_scope :order => 'comments.created at sec'
end
Controller
def show
@entry = Entry.find(params[:id])
@comments = @entry.comments.all
...
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @entry }
end
end
The view is a simple:
<% if @entry.state > 2 %>
<section id="comments">
<% @comments.each do |comment| %>
...loop some stuff...
Upvotes: 0
Views: 83
Reputation: 10103
It looks like you want :order => 'comments.created_at desc'
, not sec
.
Upvotes: 2
Reputation: 26861
And what exactly is the error you are receiving?
I think your error is from here:
default_scope :order => 'comments.created at sec'
Because comments.created at sec
you can't have that field in DB
Upvotes: 0