Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add post form

  • Loading branch information...
commit 9348397511c0a3db5c7ff0a7f49282a64a54d1b5 1 parent 1bc7af5
@laknock authored
View
2  app/assets/stylesheets/style.css.scss
@@ -10,3 +10,5 @@ body {
.admin-container {
margin-top: 10px;
}
+
+/*Post form*/
View
2  app/controllers/posts_controller.rb
@@ -4,6 +4,6 @@ class PostsController < ApplicationController
layout "writers"
def new
-
+ @post = Post.new
end
end
View
11 app/views/layouts/writers.html.erb
@@ -5,6 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
+ <%= javascript_include_tag 'ckeditor/ckeditor.js' %>
+ <script type="text/javascript">
+ $(document).ready(function() {
+ if ($('textarea').length > 0) {
+ var data = $('textarea');
+ $.each(data, function(i) {
+ CKEDITOR.replace(data[i].id);
+ });
+ }
+ });
+ </script>
<%= csrf_meta_tags %>
</head>
<body>
View
16 app/views/posts/new.html.erb
@@ -1,3 +1,17 @@
<div class="container">
-<h1>new post</h1>
+ <%= form_for @post, :html => { :class => "form-horizontal" } do |f| %>
+ <legend>Create New Post</legend>
+
+ <div class="row">
+ <%= f.label :title, :class => "span2" %>
+ <%= f.text_field :title, :class=> "span7" %>
+ </div>
+ <%= f.label :content %>
+ <%= f.text_area :content %>
+
+ <div class="form-actions">
+ <%= f.submit "Create", :class => "btn btn-primary" %>
+ <%= f.submit "Draft", :class => "btn btn-success" %>
+ </div>
+ <% end %>
</div>
View
7 spec/controllers/posts_controller_spec.rb
@@ -2,8 +2,13 @@
describe PostsController do
describe "GET #new" do
+ before(:each) do
+ sign_in FactoryGirl.create(:writer)
+ end
+
it "should show new template" do
-
+ get :new
+ response.should render_template(:new)
end
end
end
View
10 spec/factories/posts.rb
@@ -3,6 +3,14 @@
FactoryGirl.define do
factory :post do
title "Test Post 1"
- content "This is a test content message."
+ content <<-HERE
+ 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."
+ HERE
+
end
end
View
4 spec/factories/writers.rb
@@ -2,6 +2,8 @@
FactoryGirl.define do
factory :writer do
-
+ email "mariko@akb.48"
+ password "shinoda"
+ password_confirmation "shinoda"
end
end
View
4 spec/models/writer_spec.rb
@@ -20,5 +20,9 @@
require 'spec_helper'
describe Writer do
+ it "should have valid factory" do
+ FactoryGirl.create(:writer).should be_valid
+ end
+
it { should have_many(:posts) }
end
Please sign in to comment.
Something went wrong with that request. Please try again.