what i am trying to achieve is relatively simple. I have different scopes for each page type in a page model. So in my controller I do this,
def employer
@body_class = "employer membership"
is_page_present?(:employer_pages) #this checks to see if a page has user generated content for the controller action
end
private
def set_panel_sections(page)
@page_data = CorporatePage.page.last
@section_one = @page_data.corporate_panels.section_one
@section_two = @page_data.corporate_panels.section_two
end
def is_page_present?(page_type)
if CorporatePage.("#{page_type}").any?
raise
set_panel_sections(page_type)
else
@section_one = nil
end
end
I have tried different variations, including without concatenation, but all to no avail.
I get the error
undefined method `call' for #<Class:0x007f833b40b8f0>
and without the concatenation i get undefined method page_type
But in my rails console I can do this..
2.1.2 :001 > CorporatePage.employer_page.any?
(19.2ms) SELECT COUNT(*) FROM `corporate_pages` WHERE `corporate_pages`.`static_descriptor` = 'employer'
=> true
2.1.2 :002 > CorporatePage.employee_page.any?
(0.5ms) SELECT COUNT(*) FROM `corporate_pages` WHERE `corporate_pages`.`static_descriptor` = 'employee'
=> false
So, for a more insightful answer I want to know, a method call isnt a string or a symbol, what is it?
How do I fix this current issue?
Thanks