lib/alchemy/custom/model/pages_controller_dec.rb in alchemy-custom-model-0.1.3 vs lib/alchemy/custom/model/pages_controller_dec.rb in alchemy-custom-model-0.1.4

- old
+ new

@@ -42,22 +42,25 @@ parent_page = Alchemy::Language.current.pages.contentpages.find_by( urlname: url_params[:page_name], language_code: params[:locale] || Alchemy::Language.current.code ) + if parent_page.nil? + raise ActionController::RoutingError, "Parent Page not Found [#{url_params[:page_name]}]" + end #TODO magari implementare ricerca children in base a una action es. edit new chow ecc @page = parent_page.children.first if @page.nil? - raise "You have to define a subpage for custom model" + raise ActionController::RoutingError, "You have to define a subpage for custom model" end custom_model_string = get_custom_model_string if custom_model_string.blank? - raise "You have to specify custom_model in page_layouts config file" + raise ActionController::RoutingError, "You have to specify custom_model in page_layouts config file" else custom_model = custom_model_string.classify.constantize @custom_element = custom_model.only_current_language.friendly.find(url_params[:custom_model_id]) instance_variable_set("@#{custom_model_string.demodulize.underscore}", @custom_element) end \ No newline at end of file