I have an extension for RefineryCMS. In that extension I need to get data from object Block in the PagesController.
My code:
def show
if should_skip_to_first_child?
redirect_to refinery.url_for(first_live_child.url) and return
elsif page.link_url.present?
redirect_to page.link_url and return
elsif should_redirect_to_friendly_url?
redirect_to refinery.url_for(page.url), :status => 301 and return
end
@block = Refinery::Blocks::BlocksController::Block.find_by(:name => 'Footer')
render_with_templates?
end
In development the first launch is successful, but after refreshing or redirecting to another site's page:
uninitialized constant Refinery::Blocks::BlocksController::Block
can you paste whole code of your controller and model.
I think problem in this line.
@block = Refinery::Blocks::BlocksController::Block.find_by(:name => 'Footer')
You are trying to access from controller.
Use Model name like
Module::Model.find_by(:name => "Footer")