mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Refactor controllers to make more sense.
This commit is contained in:
parent
525fda2911
commit
3dd213e140
@ -1,5 +1,4 @@
|
||||
class CategoriesController < ApplicationController
|
||||
layout "photos"
|
||||
# GET /categories
|
||||
# GET /categories.xml
|
||||
def index
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
class ContactsController < ApplicationController
|
||||
layout "photos"
|
||||
|
||||
def new
|
||||
@contact = Contact.new(:id => 1)
|
||||
@page_title = 'Contact'
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
@photo = Photo.featured.order('RANDOM()').first
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
class PagesController < ApplicationController
|
||||
layout "photos"
|
||||
|
||||
def index
|
||||
@photo = Photo.featured.order('RANDOM()').first
|
||||
end
|
||||
|
||||
def about
|
||||
@page = Page.find_by_name('about')
|
||||
@content = @page.content
|
||||
@page_title = 'About'
|
||||
def show
|
||||
@page = Page.find_by_name(params[:name])
|
||||
@page_title = @page.title
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<div class="sg-5 about">
|
||||
<%= link_to raw('<span>about</span>'), about_path %>
|
||||
<%= link_to raw('<span>about</span>'), page_path(:about) %>
|
||||
</div>
|
||||
<div class="sg-5 portfolio">
|
||||
<%= link_to raw('<span>portfolio</span>'), :controller => 'categories' %>
|
||||
@ -1 +0,0 @@
|
||||
%h1= APP_CONFIG['name']
|
||||
@ -1,9 +0,0 @@
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%title= APP_CONFIG['name']
|
||||
= stylesheet_link_tag "application"
|
||||
= javascript_include_tag "application"
|
||||
= csrf_meta_tags
|
||||
%body
|
||||
= yield
|
||||
@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
||||
<title>Categories: <%= controller.action_name %></title>
|
||||
<%= stylesheet_link_tag 'scaffold' %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
<div class="sg-11 about-content">
|
||||
<div>
|
||||
<%= raw(@content.to_html) %>
|
||||
<%= raw(@page.content.to_html) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -93,16 +93,17 @@ DanBarberPhoto::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
match 'about' => 'pages#about', :as => :about
|
||||
#match 'contact' => 'pages#contact', :as => :contact
|
||||
resources :contacts, :only => [:new, :create]
|
||||
|
||||
match '/:name' => 'pages#show', :as => :page
|
||||
|
||||
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
||||
# Note: This route will make all actions in every controller accessible via GET requests.
|
||||
# match ':controller(/:action(/:id(.:format)))'
|
||||
|
||||
# root :to => 'welcome#index'
|
||||
root :to => 'pages#index'
|
||||
root :to => 'home#index'
|
||||
|
||||
# See how all your routes lay out with "rake routes"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user