Created
November 24, 2011 12:12
-
-
Save Znow/1391211 to your computer and use it in GitHub Desktop.
show method of pages_controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IN ADMIN NAMESPACE | |
# IVE TRIED WORKING IN THE MERCURY_UPDATE METHOD IN HERE BUT NO LUCK | |
# | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show | |
@page = AdvicePage.where(:slug => request.path).last | |
@path = request.path | |
end | |
def mercury_update | |
page = AdvicePage.where(:slug => request.path).last | |
page.name = params[:content][:page_title][:value] | |
page.content = params[:content][:page_content][:value] | |
page.save! | |
render text: "" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IVE TRIED FIDDLING AROUND WITH WHERE TO PUT THE LINE "=... | |
# and ive switched out LINE 44-46 with LINE 38, since migrations failed with the old method | |
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' | |
resources :pages do | |
member { post :mercury_update } | |
end | |
# AdvicePage.all.each do |r| | |
# match r.slug, :to => "pages#show" | |
# end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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", "/admin/editor/advice_pages" + request.path, id: "edit_link", data: {save_url: mercury_update_page_path(@page)} | |
- if Rails.env.development? | |
= @path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment