Skip to content

Commit

Permalink
lesson 10 - routes and rest
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvlopes committed Aug 22, 2012
1 parent caddd5a commit facc9e3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/controllers/admin/posts_controller.rb
@@ -1,6 +1,6 @@
class Admin::PostsController < Admin::BaseController

before_filter :load_resources, :only => %w(new create edit update)
before_filter :load_resources, only: %w(new create edit update)

def index
@posts = Post.all
Expand All @@ -9,7 +9,10 @@ def index

def show
@post = Post.find(params[:id])
render :layout => "application"

respond_with @post do |format|
format.html { render :layout => "application" }
end
end

def new
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/pages_controller.rb
Expand Up @@ -4,4 +4,10 @@ def index
@user = User.first
end

def prices
end

def tour
end

end
3 changes: 3 additions & 0 deletions app/views/pages/prices.html.erb
@@ -0,0 +1,3 @@
<h1>Prices</h1>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
3 changes: 3 additions & 0 deletions app/views/pages/tour.html.erb
@@ -0,0 +1,3 @@
<h1>Tour</h1>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
3 changes: 3 additions & 0 deletions config/routes.rb
Expand Up @@ -2,6 +2,9 @@

root to: 'pages#index'
get "pages/index"
match '/home' => "pages#index", :as => :home
match '/prices' => "pages#prices", :as => :prices
match '/tour' => "pages#tour", :as => :tour

resources :posts, only: [:index, :show] do
resources :comments, :only => [:create]
Expand Down

0 comments on commit facc9e3

Please sign in to comment.