Changeset 953
- Timestamp:
- 11/11/07 20:04:48 (1 year ago)
- Files:
-
- apps/merki/trunk/app/controllers/application.rb (modified) (1 diff)
- apps/merki/trunk/app/controllers/pages.rb (modified) (2 diffs)
- apps/merki/trunk/app/models/page.rb (modified) (1 diff)
- apps/merki/trunk/app/views/layout/application.html.erb (modified) (1 diff)
- apps/merki/trunk/app/views/pages/edit.html.erb (modified) (1 diff)
- apps/merki/trunk/app/views/pages/new.html.erb (modified) (1 diff)
- apps/merki/trunk/config/router.rb (modified) (1 diff)
- apps/merki/trunk/spec/controllers/pages_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
apps/merki/trunk/app/controllers/application.rb
r930 r953 1 1 # all your other controllers should inherit from this one to share code. 2 2 class Application < Merb::Controller 3 before :load_pages 4 def load_pages 5 @pages = Page.all(:order => "id DESC") 6 end 3 7 end apps/merki/trunk/app/controllers/pages.rb
r944 r953 6 6 redirect url(:page, @page) 7 7 else 8 "Uh oh! Home Page not found."8 redirect url(:new_page) 9 9 end 10 10 end 11 11 12 12 def show(id) 13 @page = Page.find_by_slug(id) 13 @page = Page.find_by_slug(id) || Page[id] 14 14 raise NotFound unless @page 15 15 render @page … … 37 37 38 38 def update(id, page) 39 @page = Page[id] 40 raise BadRequest unless @page 39 @page = Page.find id 40 # puts @page 41 # raise BadRequest if @page.nil? 41 42 if @page.update_attributes(page) 42 43 redirect url(:page, @page) apps/merki/trunk/app/models/page.rb
r952 r953 5 5 6 6 ## props 7 property :title, :string 8 property :body, :text 9 property :converted_body, :text 7 property :title, :string, :lazy => false 8 property :body, :text, :lazy => false 9 property :converted_body, :text, :lazy => false 10 11 # attribs 12 property :created_at, :datetime 13 property :updated_at, :datetime 10 14 11 15 ## relationships apps/merki/trunk/app/views/layout/application.html.erb
r931 r953 2 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us"> 3 3 <head> 4 <title> Fresh Merb App</title>4 <title>Merki :: <%= catch_content(:page_title) -%></title> 5 5 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 6 <link rel="stylesheet" href="/stylesheets/ master.css" type="text/css" media="screen" charset="utf-8">6 <link rel="stylesheet" href="/stylesheets/site.css" type="text/css" media="screen" charset="utf-8"> 7 7 </head> 8 8 <body> 9 <%= catch_content :layout %> 9 10 <div id="sidebar"> 11 <%= partial("layout/sidebar") -%> 12 </div> <!-- close: sidebar --> 13 14 <div id="content"> 15 <%= catch_content :layout %> 16 </div> <!-- close: content --> 17 10 18 </body> 11 19 </html> apps/merki/trunk/app/views/pages/edit.html.erb
r943 r953 1 Edit for Pages 1 <h1 id="edit">Edit Page</h1> 2 <% form_for @page, :action => url(:page, @page) do -%> 3 <%= partial "form" -%> 4 <div class="form-row"> 5 <label></label> 6 <%= submit_button "Edit" -%> 7 </div> <!-- close: --> 8 <% end -%> apps/merki/trunk/app/views/pages/new.html.erb
r943 r953 1 New for Pages 1 <h1>Create Page</h1> 2 3 <% form_for @page, :action => url(:pages) do -%> 4 <%= partial("form") -%> 5 6 <div class="form-row"> 7 <label></label> 8 <%= submit_button "Create" -%> 9 </div> <!-- close: --> 10 <% end -%> apps/merki/trunk/config/router.rb
r942 r953 25 25 26 26 r.match('/').to(:controller => 'pages', :action =>'index') 27 28 r.default_routes 27 29 end apps/merki/trunk/spec/controllers/pages_spec.rb
r943 r953 31 31 32 32 it "should display an error" do 33 pending "now forwards to NewPage" 33 34 @controller.body.should match(/Home Page not found/) 34 35 end
