Closed namsterdamus closed 9 years ago
Hello,
What line/file is reported at the top of the backtrace? If it's in the config, make sure your lambdas can handle nil users.
If it's in one of the controllers or views, then it's my fault.
Looks like it's in the controller
app/controllers/pins_controller.rb:20:in `show'
commontator (4.10.0) app/models/commontator/comment.rb:81:in `can_be_created_by?'
commontator (4.10.0) lib/commontator/controller_includes.rb:17:in `commontator_set_new_comment'
commontator (4.10.0) lib/commontator/controller_includes.rb:28:in `commontator_thread_show'
app/controllers/pins_controller.rb:20:in `show'
actionpack (4.1.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
btw my config looks like this
config.current_user_proc = lambda { |controller| controller.current_user }
config.user_name_proc = lambda { |user| user.name }
config.thread_read_proc = lambda { |thread, user| true }
Should be fixed in 4.10.1
Awesome, works fine now. thanks.
opps well now it's got another problem on the production server instead of the dev server almost the same as the last one but slightly different.
ActionView::Template::Error (undefined method `can_be_read_by?' for nil:NilClass):
3: # user
4: %>
5:
6: <% if thread.can_be_read_by?(user) %>
7: <%= stylesheet_link_tag "commontator/application.css", :media => "all" %>
8:
9: <div id="thread_<%= thread.id %>_div" class="thread" style="display: none;">
app/views/commontator/shared/_thread.html.erb:6:in
_app_views_commontator_shared__thread_html_erb__3096579250552697194_70317560651440'
app/views/pins/show.html.erb:67:in
_app_views_pins_show_html_erb__2157342071576738619_70317562671240'
app/controllers/pins_controller.rb:19:in `show'
Looks like on the production instead of is_commentator now can_be_read_by is coming up as nil
I'm guess that it's not passing to thread.can_be_read_by?
def can_be_created_by?(user)
user == creator && !user.nil? && user.is_commontator &&\
!thread.is_closed? && thread.can_be_read_by?(user)
end
This one is the same as https://github.com/lml/commontator/issues/52 Guess I should fix it asap...
Oh i see that too they are saying in #52 that it has to do with no thread for existing post huh?
So aside from you fixing it i guess the alternative for some people is dumping the db and starting from scratch, probably fine for new build but impossible for those with an active db.
Fixed in 4.10.2
Closing. Please open a new issue if still a problem.
Basically it works perfectly fine when a user is logged in. However when I log out and go to a page with the commentator_thread(@pin) then it breaks with this message.
NoMethodError in PinsController#show undefined method `is_commontator' for nil:NilClass
The controller currently is as follows
And the view is as follows:
It's pretty basic. My guess was that it requires a current_user to not be nil so my alternative to fixing it was to to just put an if statement to only show the comments if they are logged in but what if I want it to always be visible?