NoMethodError in PopularController#gk_detail

undefined method `id' for nil:NilClass

Extracted source (around line #308):
306
307
308
309
310
311
          
def gk_detail
@pageid = Page.find_by_permalink(params[:id])
@pagesec = Section.where(:page_id => @pageid.id)
@pagecom = Comment.visible.where(:page_id => @pageid.id)
@otherpage = Page.where(:subject_id => @pageid.subject_id,:sub_subject_id => @pageid.sub_subject_id).order("RAND()").limit(1)
if @otherpage.blank?

Rails.root: /home/rails

Application Trace | Framework Trace | Full Trace
app/controllers/popular_controller.rb:308:in `gk_detail'

Request

Parameters:

{"id"=>"alzheimer%E2%80%99s-disease"}

Response

Headers:

None