zen_seo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.gitignore +12 -0
  2. data/.gitignore~ +7 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +22 -0
  5. data/Gemfile.lock +115 -0
  6. data/README.md +88 -0
  7. data/lib/zen_seo/base.rb +5 -4
  8. data/lib/zen_seo/controller_helper.rb +1 -0
  9. data/lib/zen_seo/version.rb +1 -1
  10. data/{test → spec}/dummy/README.rdoc +0 -0
  11. data/{test → spec}/dummy/Rakefile +0 -0
  12. data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
  13. data/spec/dummy/app/assets/javascripts/posts.js +2 -0
  14. data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
  15. data/spec/dummy/app/assets/stylesheets/posts.css +4 -0
  16. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  17. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
  18. data/spec/dummy/app/controllers/posts_controller.rb +83 -0
  19. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  20. data/spec/dummy/app/helpers/posts_helper.rb +2 -0
  21. data/{test/dummy/public/favicon.ico → spec/dummy/app/mailers/.gitkeep} +0 -0
  22. data/spec/dummy/app/models/.gitkeep +0 -0
  23. data/spec/dummy/app/models/post.rb +8 -0
  24. data/{test → spec}/dummy/app/views/layouts/application.html.erb +1 -0
  25. data/spec/dummy/app/views/posts/_form.html.erb +43 -0
  26. data/spec/dummy/app/views/posts/edit.html.erb +6 -0
  27. data/spec/dummy/app/views/posts/index.html.erb +27 -0
  28. data/spec/dummy/app/views/posts/new.html.erb +5 -0
  29. data/spec/dummy/app/views/posts/show.html.erb +20 -0
  30. data/{test → spec}/dummy/config/application.rb +0 -0
  31. data/{test → spec}/dummy/config/boot.rb +0 -0
  32. data/{test → spec}/dummy/config/database.yml +0 -0
  33. data/{test → spec}/dummy/config/environment.rb +0 -0
  34. data/{test → spec}/dummy/config/environments/development.rb +0 -0
  35. data/{test → spec}/dummy/config/environments/production.rb +0 -0
  36. data/{test → spec}/dummy/config/environments/test.rb +0 -0
  37. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  38. data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
  39. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
  40. data/{test → spec}/dummy/config/initializers/secret_token.rb +0 -0
  41. data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
  42. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
  43. data/{test → spec}/dummy/config/locales/en.yml +0 -0
  44. data/{test → spec}/dummy/config/routes.rb +4 -0
  45. data/{test → spec}/dummy/config.ru +0 -0
  46. data/spec/dummy/db/development.sqlite3 +0 -0
  47. data/spec/dummy/db/migrate/20130329073248_create_posts.rb +11 -0
  48. data/spec/dummy/db/migrate/20130329073304_create_seos.rb +12 -0
  49. data/spec/dummy/db/schema.rb +34 -0
  50. data/spec/dummy/lib/assets/.gitkeep +0 -0
  51. data/spec/dummy/log/.gitkeep +0 -0
  52. data/spec/dummy/log/development.log +711 -0
  53. data/{test → spec}/dummy/public/404.html +0 -0
  54. data/{test → spec}/dummy/public/422.html +0 -0
  55. data/{test → spec}/dummy/public/500.html +0 -0
  56. data/spec/dummy/public/favicon.ico +0 -0
  57. data/{test → spec}/dummy/script/rails +0 -0
  58. data/spec/dummy/test/fixtures/posts.yml +11 -0
  59. data/spec/dummy/test/functional/posts_controller_test.rb +49 -0
  60. data/spec/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  61. data/spec/dummy/test/unit/post_test.rb +7 -0
  62. data/spec/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212 +0 -0
  63. data/spec/dummy/tmp/cache/assets/CAB/2B0/sprockets%2F7f42b56265da60e2e55070da5209187e +0 -0
  64. data/spec/dummy/tmp/cache/assets/CC7/220/sprockets%2Fd066c004d1fd26ae76a61303a7a18145 +0 -0
  65. data/spec/dummy/tmp/cache/assets/CD5/B70/sprockets%2F416150dc3ac35079c94273cc46e90aa6 +0 -0
  66. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  67. data/spec/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +0 -0
  68. data/spec/dummy/tmp/cache/assets/D1A/310/sprockets%2F5384ad85f52d3272dbc64d46ef3876a4 +0 -0
  69. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  70. data/spec/dummy/tmp/cache/assets/D4C/0A0/sprockets%2F128b787007ed7bcc496f2cfe954054df +0 -0
  71. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  72. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  73. data/spec/dummy/tmp/cache/assets/D9C/CD0/sprockets%2Fc85016e7bbd4f3adbb7635d01f85d39b +0 -0
  74. data/spec/dummy/tmp/cache/assets/DA0/4D0/sprockets%2F621e6ac32f63ecb1fcd158c408cd877f +0 -0
  75. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  76. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  77. data/spec/dummy/tmp/cache/assets/E1C/CF0/sprockets%2Fa1bfe0c8cb9c6a2d3b00a914dcdfb494 +0 -0
  78. data/spec/spec_helper.rb +22 -0
  79. data/spec/zen_seo_spec.rb +43 -0
  80. data/zen_seo.gemspec +30 -0
  81. data/zen_seo.gemspec~ +28 -0
  82. metadata +155 -71
  83. data/test/test_helper.rb +0 -15
  84. data/test/zen_seo_test.rb +0 -7
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ .bundle/
2
+ .idea
3
+ log/*.log
4
+ pkg/
5
+ test/dummy/db/*.sqlite3
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ test/dummy/.sass-cache
9
+ spec/dummy/db/*.sqlite3
10
+ spec/dummy/log/*.log
11
+ spec/dummy/tmp/
12
+ spec/dummy/.sass-cache
data/.gitignore~ ADDED
@@ -0,0 +1,7 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/log/*.log
6
+ test/dummy/tmp/
7
+ test/dummy/.sass-cache
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in zen_seo.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # jquery-rails is used by the dummy application
9
+ gem "jquery-rails"
10
+ gem 'sqlite3'
11
+ gem 'meta-tags', :require=>'meta_tags'
12
+ gem 'quiet_assets'
13
+
14
+ gem 'rspec'
15
+
16
+ # Declare any dependencies that are still in development here instead of in
17
+ # your gemspec. These might include edge Rails or gems from your path or
18
+ # Git. Remember to move these dependencies to your gemspec before releasing
19
+ # your gem to rubygems.org.
20
+
21
+ # To use debugger
22
+ # gem 'debugger'
data/Gemfile.lock ADDED
@@ -0,0 +1,115 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ zen_seo (0.0.2)
5
+ meta-tags
6
+ rails (~> 3.2.13)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.13)
12
+ actionpack (= 3.2.13)
13
+ mail (~> 2.5.3)
14
+ actionpack (3.2.13)
15
+ activemodel (= 3.2.13)
16
+ activesupport (= 3.2.13)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.4)
20
+ rack (~> 1.4.5)
21
+ rack-cache (~> 1.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.2.1)
24
+ activemodel (3.2.13)
25
+ activesupport (= 3.2.13)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.13)
28
+ activemodel (= 3.2.13)
29
+ activesupport (= 3.2.13)
30
+ arel (~> 3.0.2)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.13)
33
+ activemodel (= 3.2.13)
34
+ activesupport (= 3.2.13)
35
+ activesupport (3.2.13)
36
+ i18n (= 0.6.1)
37
+ multi_json (~> 1.0)
38
+ arel (3.0.2)
39
+ builder (3.0.4)
40
+ diff-lcs (1.2.1)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.1)
44
+ journey (1.0.4)
45
+ jquery-rails (2.2.1)
46
+ railties (>= 3.0, < 5.0)
47
+ thor (>= 0.14, < 2.0)
48
+ json (1.7.7)
49
+ mail (2.5.3)
50
+ i18n (>= 0.4.0)
51
+ mime-types (~> 1.16)
52
+ treetop (~> 1.4.8)
53
+ meta-tags (1.4.1)
54
+ actionpack
55
+ mime-types (1.21)
56
+ multi_json (1.7.2)
57
+ polyglot (0.3.3)
58
+ quiet_assets (1.0.2)
59
+ railties (>= 3.1, < 5.0)
60
+ rack (1.4.5)
61
+ rack-cache (1.2)
62
+ rack (>= 0.4)
63
+ rack-ssl (1.3.3)
64
+ rack
65
+ rack-test (0.6.2)
66
+ rack (>= 1.0)
67
+ rails (3.2.13)
68
+ actionmailer (= 3.2.13)
69
+ actionpack (= 3.2.13)
70
+ activerecord (= 3.2.13)
71
+ activeresource (= 3.2.13)
72
+ activesupport (= 3.2.13)
73
+ bundler (~> 1.0)
74
+ railties (= 3.2.13)
75
+ railties (3.2.13)
76
+ actionpack (= 3.2.13)
77
+ activesupport (= 3.2.13)
78
+ rack-ssl (~> 1.3.2)
79
+ rake (>= 0.8.7)
80
+ rdoc (~> 3.4)
81
+ thor (>= 0.14.6, < 2.0)
82
+ rake (10.0.4)
83
+ rdoc (3.12.2)
84
+ json (~> 1.4)
85
+ rspec (2.13.0)
86
+ rspec-core (~> 2.13.0)
87
+ rspec-expectations (~> 2.13.0)
88
+ rspec-mocks (~> 2.13.0)
89
+ rspec-core (2.13.1)
90
+ rspec-expectations (2.13.0)
91
+ diff-lcs (>= 1.1.3, < 2.0)
92
+ rspec-mocks (2.13.0)
93
+ sprockets (2.2.2)
94
+ hike (~> 1.2)
95
+ multi_json (~> 1.0)
96
+ rack (~> 1.0)
97
+ tilt (~> 1.1, != 1.3.0)
98
+ sqlite3 (1.3.7)
99
+ thor (0.18.0)
100
+ tilt (1.3.6)
101
+ treetop (1.4.12)
102
+ polyglot
103
+ polyglot (>= 0.3.1)
104
+ tzinfo (0.3.37)
105
+
106
+ PLATFORMS
107
+ ruby
108
+
109
+ DEPENDENCIES
110
+ jquery-rails
111
+ meta-tags
112
+ quiet_assets
113
+ rspec
114
+ sqlite3
115
+ zen_seo!
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ #ZEN_SEO is a clean way of managing your meta tags for resources
2
+ ## Install
3
+ Hope all of us are at least on Rails3 and moving to upcoming Rails4(unsupported for now)
4
+ ```sh
5
+ # Gemfile
6
+ gem 'zen_seo'
7
+ ```
8
+ Then run the install generator, that will create migration(MongoDB is on the routemap) for the SEO model.
9
+ ```sh
10
+ rails generate zen_seo:install
11
+ ```
12
+
13
+ ## Usage
14
+ Pick up a resource to grant a promotable behavior
15
+ ### Model
16
+
17
+ ```ruby
18
+ #app/models/post.rb
19
+ has_seo
20
+ ```
21
+
22
+ This will try to call `title`, `description`, `keywords` on your model to fill in seo fields, optionally you can supply a hash, that redefines the methods to be called
23
+
24
+ ```ruby
25
+ #app/models/post.rb
26
+ class Post < ActiveRecord::Base
27
+ attr_accessible :body, :tags, :title
28
+ has_seo :description=>:body, :keywords=>:make_keywords
29
+
30
+ private
31
+ def make_keywords
32
+ self.tags.gsub(/:/, ', ')
33
+ end
34
+ end
35
+ ```
36
+
37
+ ###Controller
38
+
39
+ ZEN_SEO heavily based on [meta_tags](https://github.com/kpumuk/meta-tags) gem, so set it up as normal.
40
+
41
+ When your layout contains
42
+ ```ruby
43
+ #application.html.erb
44
+ <head>
45
+ <%= display_meta_tags default_meta_tags %>
46
+ </head>
47
+ ```
48
+ now in controller you can use `meta_tags_for` helper
49
+ ```ruby
50
+ #posts_controller.rb
51
+ # GET /posts/1
52
+ # GET /posts/1.json
53
+ def show
54
+ @post = Post.find(params[:id])
55
+ meta_tags_for @post
56
+ respond_to do |format|
57
+ format.html # show.html.erb
58
+ format.json { render json: @post }
59
+ end
60
+ end
61
+ ```
62
+ ###Form
63
+ To set meta tags for your resource just put `fields_for :seo` in your form. Like this:
64
+ ```erb
65
+ <h3>Make yout post seo-friendly</h3>
66
+ <%= f.fields_for :seo do |seo| %>
67
+ <div class="field">
68
+ <%= seo.label :title %><br />
69
+ <%= seo.text_field :title %>
70
+ </div>
71
+ <div class="field">
72
+ <%= seo.label :keywords %><br />
73
+ <%= seo.text_field :keywords %>
74
+ </div>
75
+ <div class="field">
76
+ <%= seo.label :description %><br />
77
+ <%= seo.text_area :description %>
78
+ </div>
79
+ <% end %>
80
+ ```
81
+
82
+ ## Note on Patches/Pull Requests
83
+
84
+ * Any help on issues-fighting(or finding) and testing is highly appreciated
85
+
86
+ ## Copyright
87
+
88
+ Sergey Prikhodko originally developed by Jared Pace Copyright (c) 2010. See LICENSE for details.
data/lib/zen_seo/base.rb CHANGED
@@ -6,7 +6,8 @@ module ZenSeo
6
6
  end
7
7
 
8
8
  def has_seo_config(options={})
9
- @has_seo_config ||= options
9
+ defaults={title: :title, description: :description, keywords: :keywords}
10
+ @has_seo_config ||= defaults.merge options
10
11
  end
11
12
 
12
13
  end
@@ -36,9 +37,9 @@ module ZenSeo
36
37
  end
37
38
 
38
39
  def generate_seo_fields
39
- seo.title ||= self.send (has_seo_config[:title] || :title)
40
- seo.description ||= self.send (has_seo_config[:description] || :description)
41
- seo.keywords ||= self.send (has_seo_config[:keywords] || :keywords)
40
+ seo.title= self.send (has_seo_config[:title]) if seo.title.blank?
41
+ seo.description= self.send (has_seo_config[:description]) if seo.description.blank?
42
+ seo.keywords= self.send (has_seo_config[:keywords]) if seo.keywords.blank?
42
43
  end
43
44
 
44
45
  end
@@ -10,6 +10,7 @@ module ZenSeo
10
10
  :description=>model.seo.description,
11
11
  :keywords=>model.seo.keywords
12
12
  end
13
+ alias :meta_for :meta_tags_for
13
14
  protected :meta_tags_for
14
15
  end
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module ZenSeo
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,83 @@
1
+ class PostsController < ApplicationController
2
+ # GET /posts
3
+ # GET /posts.json
4
+ def index
5
+ @posts = Post.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.json { render json: @posts }
10
+ end
11
+ end
12
+
13
+ # GET /posts/1
14
+ # GET /posts/1.json
15
+ def show
16
+ @post = Post.find(params[:id])
17
+ meta_tags_for @post
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.json { render json: @post }
21
+ end
22
+ end
23
+
24
+ # GET /posts/new
25
+ # GET /posts/new.json
26
+ def new
27
+ @post = Post.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.json { render json: @post }
32
+ end
33
+ end
34
+
35
+ # GET /posts/1/edit
36
+ def edit
37
+ @post = Post.find(params[:id])
38
+ end
39
+
40
+ # POST /posts
41
+ # POST /posts.json
42
+ def create
43
+ @post = Post.new(params[:post])
44
+
45
+ respond_to do |format|
46
+ if @post.save
47
+ format.html { redirect_to @post, notice: 'Post was successfully created.' }
48
+ format.json { render json: @post, status: :created, location: @post }
49
+ else
50
+ format.html { render action: "new" }
51
+ format.json { render json: @post.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /posts/1
57
+ # PUT /posts/1.json
58
+ def update
59
+ @post = Post.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @post.update_attributes(params[:post])
63
+ format.html { redirect_to @post, notice: 'Post was successfully updated.' }
64
+ format.json { head :no_content }
65
+ else
66
+ format.html { render action: "edit" }
67
+ format.json { render json: @post.errors, status: :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /posts/1
73
+ # DELETE /posts/1.json
74
+ def destroy
75
+ @post = Post.find(params[:id])
76
+ @post.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to posts_url }
80
+ format.json { head :no_content }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,2 @@
1
+ module PostsHelper
2
+ end
File without changes
@@ -0,0 +1,8 @@
1
+ class Post < ActiveRecord::Base
2
+ attr_accessible :body, :tags, :title
3
+ has_seo :description=>:body, :keywords=>:make_keywords
4
+ private
5
+ def make_keywords
6
+ self.tags.gsub(/:/, ', ')
7
+ end
8
+ end
@@ -2,6 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dummy</title>
5
+ <%= display_meta_tags %>
5
6
  <%= stylesheet_link_tag "application", :media => "all" %>
6
7
  <%= javascript_include_tag "application" %>
7
8
  <%= csrf_meta_tags %>
@@ -0,0 +1,43 @@
1
+ <%= form_for(@post) do |f| %>
2
+ <% if @post.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @post.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+ <div class="field">
14
+ <%= f.label :title %><br />
15
+ <%= f.text_field :title %>
16
+ </div>
17
+ <div class="field">
18
+ <%= f.label :body %><br />
19
+ <%= f.text_area :body %>
20
+ </div>
21
+ <div class="field">
22
+ <%= f.label :tags %><br />
23
+ <%= f.text_area :tags %>
24
+ </div>
25
+ <h3>Make yout post seo-friendly</h3>
26
+ <%= f.fields_for :seo do |seo| %>
27
+ <div class="field">
28
+ <%= seo.label :title %><br />
29
+ <%= seo.text_field :title %>
30
+ </div>
31
+ <div class="field">
32
+ <%= seo.label :keywords %><br />
33
+ <%= seo.text_field :keywords %>
34
+ </div>
35
+ <div class="field">
36
+ <%= seo.label :description %><br />
37
+ <%= seo.text_area :description %>
38
+ </div>
39
+ <% end %>
40
+ <div class="actions">
41
+ <%= f.submit %>
42
+ </div>
43
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing post</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @post %> |
6
+ <%= link_to 'Back', posts_path %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing posts</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Body</th>
7
+ <th>Tags</th>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <% @posts.each do |post| %>
14
+ <tr>
15
+ <td><%= post.title %></td>
16
+ <td><%= post.body %></td>
17
+ <td><%= post.tags %></td>
18
+ <td><%= link_to 'Show', post %></td>
19
+ <td><%= link_to 'Edit', edit_post_path(post) %></td>
20
+ <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
21
+ </tr>
22
+ <% end %>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%= link_to 'New Post', new_post_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New post</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', posts_path %>
@@ -0,0 +1,20 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Title:</b>
5
+ <%= @post.title %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Body:</b>
10
+ <%= @post.body %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Tags:</b>
15
+ <%= @post.tags %>
16
+ </p>
17
+
18
+
19
+ <%= link_to 'Edit', edit_post_path(@post) %> |
20
+ <%= link_to 'Back', posts_path %>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,8 @@
1
1
  Dummy::Application.routes.draw do
2
+ root to: 'posts#index'
3
+ resources :posts
4
+
5
+
2
6
  # The priority is based upon order of creation:
3
7
  # first created -> highest priority.
4
8
 
File without changes
Binary file
@@ -0,0 +1,11 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :posts do |t|
4
+ t.string :title
5
+ t.text :body
6
+ t.text :tags
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateSeos < ActiveRecord::Migration
2
+ def change
3
+ create_table :seos do |t|
4
+ t.string :title
5
+ t.text :description
6
+ t.text :keywords
7
+ t.references :promotable, :polymorphic=>true
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end