Permalink
Browse files

blog posts added

  • Loading branch information...
1 parent c34ec99 commit c303a8e98031411372d197639bde85faa6dab2a8 Aleksander Dabrowski committed Mar 5, 2010
@@ -0,0 +1,6 @@
+class Administration::PostsController < ApplicationController
+ resource_controller
+
+ create.wants.html {redirect_to administration_posts_path}
+ update.wants.html {redirect_to administration_posts_path}
+end
@@ -1,5 +1,6 @@
class HomeController < ApplicationController
def index
+ @posts = Post.all
end
end
View
@@ -0,0 +1,2 @@
+class Post < ActiveRecord::Base
+end
@@ -11,3 +11,8 @@
%ul
%li= link_to("New", new_administration_presentation_path)
%li= link_to("Browse", administration_presentations_path)
+ %li.blog
+ Blog posts
+ %ul
+ %li= link_to("New", new_administration_post_path)
+ %li= link_to("Manage", administration_posts_path)
@@ -0,0 +1,13 @@
+- form_for([:administration, @post]) do |f|
+ %dl
+ %dt= f.label(:title, "Title")
+ %dd
+ = f.text_field(:title)
+ = f.error_message_on(:title)
+
+ %dt= f.label(:body, "Body")
+ %dd
+ = f.text_area(:body)
+ = f.error_message_on(:body)
+
+ %p= f.submit(@post.new_record? ? "Create post" : "Update post")
@@ -0,0 +1,3 @@
+- set_head_and_page_title("Edit post")
+
+= render("form")
@@ -0,0 +1,9 @@
+- set_head_and_page_title("All blog posts")
+
+= link_to("New", new_administration_post_path)
+- @posts.each do |post|
+ %h2= h(post.title)
+ %p
+ = link_to 'edit', edit_administration_post_path(post)
+ = link_to 'delete', administration_post_path(post), :method => :delete, :confirm => 'Are you sure, you want to destroy this post'
+ %p= post.body
@@ -0,0 +1,3 @@
+- set_head_and_page_title("Write new post")
+
+= render("form")
@@ -2,7 +2,12 @@
- set_page_title(image_tag('/images/banner.jpg', :alt => 'Euruko 2010 - Kraków, Poland'))
.blog
- Blog posts goes here
+ - unless @posts.blank?
+ - @posts.each do |post|
+ %h2= h(post.title)
+ %p= post.body
+ - else
+ %p Brak postów.
.sidebar
%h2 What's EuRuKo?
@@ -8,5 +8,5 @@
%li= link_to(h("You are logged in as %s." % current_user.full_name), current_user)
- else
= menu_to "Register", new_user_path
- = menu_to "Login", new_user_session_path
+ = menu_to "Log in", new_user_session_path
View
@@ -12,6 +12,7 @@
administration.resource :admin_session
administration.resources :presentations
administration.resources :users
+ administration.resources :posts
end
map.root :controller => 'home'
@@ -0,0 +1,13 @@
+class CreatePosts < ActiveRecord::Migration
+ def self.up
+ create_table :posts do |t|
+ t.string :title
+ t.text :body
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :posts
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100218090559) do
+ActiveRecord::Schema.define(:version => 20100305002307) do
create_table "admins", :force => true do |t|
t.string "email"
@@ -45,6 +45,13 @@
add_index "billing_informations", ["user_id"], :name => "index_billing_informations_on_user_id", :unique => true
+ create_table "posts", :force => true do |t|
+ t.string "title"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "presentations", :force => true do |t|
t.string "topic", :null => false
t.text "description", :null => false
@@ -16,6 +16,8 @@ def path_to(page_name)
new_administration_admin_session_path
when /my profile data/
user_path(@current_user)
+ when /user registration page/
+ new_user_path
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
#
@@ -5,7 +5,7 @@ Feature: User accounts
Scenario: Creating user account
Given I access the site as guest
- When I go to the home page
+ When I go to the user registration page
When I fill in "E-mail" with "user@example.com"
And I fill in "Password" with "password"
And I fill in "Password confirmation" with "password"
@@ -22,8 +22,8 @@ body {
.sidebar {
float: left;
- width: 240px;
- padding-left: 20px; }
+ width: 220px;
+ padding-left: 40px; }
.sidebar img.icon {
float: left;
padding: 0 10px; }
@@ -22,8 +22,8 @@ body
.sidebar
float: left
- width: 240px
- padding-left: 20px
+ width: 220px
+ padding-left: 40px
img.icon
float: left
padding: 0 10px
@@ -1,11 +0,0 @@
-require 'spec_helper'
-
-describe "/home/index" do
- before(:each) do
- render 'home/index'
- end
-
- it "should have registration form" do
- response.should have_tag('form[action=?]', users_path)
- end
-end

0 comments on commit c303a8e

Please sign in to comment.