f0y / redmine_private_wiki

Private Wiki plugin for Redmine
http://www.redmine.org/plugins/private_wiki
MIT License
17 stars 16 forks source link

error @page is nil in function change privacy when you click hide icon at the bottom of the page while creating a wiki #1

Closed sawan1990 closed 12 years ago

sawan1990 commented 12 years ago

hide symbol comes at the bottom when creating a wiki

when clicked on it, page with error occurs which says

You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.update_attribute

on this function

def change_privacy find_existing_page @page.update_attribute :private, params[:private] redirect_to :action => 'show', :project_id => @project, :id => @page.title end

using redmine-1.3.

sawan1990 commented 12 years ago

I have found a solution to this issue, It was because while creating a new page the "Hide" link comes at the bottom. when we click that code checks the database for the page but doesn't gets it and throws execption. so better remove the link form the creation of the new page.

Q: how to do that? answer: Add one more condition to _body_bottom.html.erb ("and @page.id") the whole line is <% if controller and controller.class.name == 'WikiController' and controller.action_name == "show" and @page.id %>

After this we wont get to see the link at the bottom of page.

This will check if page exists (i.e will be difference between created page and non created page)

Hope this is the right solution, if you find any better solution please let me know. Rest ,it works fine after the page is created.