Skip to content

Instantly share code, notes, and snippets.

@Znow
Created November 24, 2011 12:37
Show Gist options
  • Save Znow/1391263 to your computer and use it in GitHub Desktop.
Save Znow/1391263 to your computer and use it in GitHub Desktop.
shows the specific page...
class Admin::AdvicePagesController < AdminController
def index
@pages = AdvicePage.all
end
def show
@page = AdvicePage.find(params[:id])
end
def mercury_update
page = AdvicePage.find(params[:id])
page.name = params[:content][:page_title][:value]
page.content = params[:content][:page_content][:value]
page.save!
render text: ""
end
def edit
@page = AdvicePage.find(params[:id])
end
def update
@page = AdvicePage.find(params[:id])
if @page.update_attributes(params[:advice_page])
redirect_to admin_advice_pages_path, :notice => 'Page was successfully updated.'
else
redirect_to edit_admin_advice_page(@page.id)
end
end
end
Advicecapital::Application.routes.draw do
Mercury::Engine.routes
match '/contact' => 'contact#new', :as => 'contact', :via => :get
match '/contact' => 'contact#create', :as => 'contact', :via => :post
devise_for :users
resources :news
resources :boards
#resources :contacts, :only => [:new, :create]
resources :videos
namespace :admin do
root :to => 'dashboard#index'
resources :advice_pages do
member { post :mercury_update }
end
resources :boxes, :only => [:index, :show, :edit, :update]
resources :investors
resources :users
resources :employees
end
root :to => "pages#index"
match '/receive_news', :to => 'pages#receive_news'
match '/disclaimer', :to => 'pages#disclaimer'
match '/organisation', :to => 'admin/employees#index'
mount Resque::Server, :at => "/resque"
match '/*slugs', :to => 'pages#show'
# AdvicePage.all.each do |r|
# match r.slug, :to => "pages#show"
# end
end
.span-20
%h3
%span#page_title.mercury-region{"data-type" => "editable"}
= raw @page.title
%p
#page_content.mercury-region{"data-type" => "editable"}
= raw @page.content
- if can? :manage, @page
= link_to "Rediger side", "/editor" + request.path, id: "edit_link", data: {save_url: mercury_update_admin_advice_page_path(@page)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment