Then in the controller (comments_controller.rb),
def create @comment = Comment.new(params[:comment])
Book.comments.create(:title => “First comment.”, :comment => “This
is the first comment.”)
end
Then when submitting a comment, it returns the error: “unknown
attribute: book_id”
From the log:
Processing by CommentsController#create as HTML
Parameters: {“comment”=>{“comment”=>“WOOOW”, “book_id”=>“32”},
“commit”=>“Post Comment”,
“authenticity_token”=>“5YbtEMpoQL1e9coAIJBOm0WD55vB2XRZMJa4MMAR1YI=”,
“utf8”=>“✓”}
Completed in 11ms
oh , awsome nested set gem arrenges item like a tree , to is like
root
|
________|__________
left | item | right
______ |__ | ______|______
you see item has a left and right sibling, the gem saves , the
parent_id
of item , in this case root and the item of the item to the left and to
the
right
Does nesting currently work in your example app OR are you still
working on implementing
it? I’m trying to decide if nesting isn’t yet done, if I should wait
until it’s up and working?
don’t really have the need for pagination but it’s helpful as a
learning tool/tutorial of sorts…
regarding a feature to add, I can actually think of one very common
feature, as seen on Facebook. If you have over 3 comments, to only
show the latest 2 comments, and then have a ajax link “View all X
comments” which when clicked loads/injects the remaining comments into
the comment list. That’s a pretty important one! A less important one,
is being able to LIKE a comment.
To get your code working in my app I needed to: @comments = @article.comments.roots.order(“created_at
DESC”).paginate( :page => params[:page]||1,:per_page => 5)
REMOVE roots in books_controller.rb: @comments = @article.comments.order(“created_at DESC”).paginate( :page
=> params[:page]||1,:per_page => 5)
And in comment.rb:
COMMENT OUT #acts_as_nested_set
Otherwise I get the error on the books show page: “uninitialized
constant Book::Comment”
Is there a GEM that needs to be installed? Or maybe this isn’t
supported for Rails 3?
the projet is done i rails three and the awesome nested set is in there
as a
plug in, is what does the nesting, if you dont use it the nesting wont
work,
can you give me more info on you book model? i want know why is not
working
well i left that out because it would make the example a little harder
to
follow what i will do is a second example that will integrate users,
then
one with users and captcha, i will add funcionality on topp of the
existing
one but as a new project so is easy to learn what’s news
the projet is done i rails three and the awesome nested set is in there as a
plug in, is what does the nesting, if you dont use it the nesting wont work,
can you give me more info on you book model? i want know why is not working
Is the plug-in in the GEM file? I’m not seeing it. Could you point it
out so I can add it to my GEM file? If the plugin isn’t via the GEM
file, how do you get it added to the rails 3 app?
no , plugins go along with the rails app. gems get installed in the
computer
your are using and if you take your rails app somewhere else you have to
install all the gems in that other computer, plugins install in the
/vendor/plugin folder in the rails app and they go where ever you app
goes,
the result is almost the same but , gems are better if you have several
project using something common, for example , most rails app use
will_paginate so is better to install it as a gem on the pc, if you
install
will paginate as a plugin you would have a copy of will_paginate in each
app, and also your app would grow as you put plugins in them.
At then i installed awesome nested set as a plugin in the vendors/plugin
directory because i needed to hack it, is not a good idea to hack a gem
as
gems as i explained are shared by all the apps in that computer.