OSDN Git Service

create author controller trying
authoryasushiito <yas@pen-chan.jp>
Sat, 14 Jan 2012 00:43:46 +0000 (09:43 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 14 Jan 2012 00:43:46 +0000 (09:43 +0900)
app/assets/javascripts/authors.js.coffee [new file with mode: 0644]
app/assets/stylesheets/authors.css.scss [new file with mode: 0644]
app/controllers/authors_controller.rb [new file with mode: 0644]
app/helpers/authors_helper.rb [new file with mode: 0644]
app/views/authors/index.html.erb [new file with mode: 0644]
app/views/authors/show.html.erb [new file with mode: 0644]
config/routes.rb
spec/controllers/authors_controller_spec.rb [new file with mode: 0644]
spec/helpers/authors_helper_spec.rb [new file with mode: 0644]

diff --git a/app/assets/javascripts/authors.js.coffee b/app/assets/javascripts/authors.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/app/assets/stylesheets/authors.css.scss b/app/assets/stylesheets/authors.css.scss
new file mode 100644 (file)
index 0000000..fb565e9
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the authors controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb
new file mode 100644 (file)
index 0000000..8386ed2
--- /dev/null
@@ -0,0 +1,19 @@
+class AuthorsController < ApplicationController
+  before_filter :authenticate_author!, :only => [:index, :show]
+  def index
+    @authors = Author.all
+
+    respond_to do |format|
+      format.html # index.html.erb
+    end
+  end
+
+  def show
+    @author = Author.find(params[:id])
+
+    respond_to do |format|
+      format.html
+    end
+  end
+
+end
diff --git a/app/helpers/authors_helper.rb b/app/helpers/authors_helper.rb
new file mode 100644 (file)
index 0000000..f22e1f9
--- /dev/null
@@ -0,0 +1,2 @@
+module AuthorsHelper
+end
diff --git a/app/views/authors/index.html.erb b/app/views/authors/index.html.erb
new file mode 100644 (file)
index 0000000..5691bbb
--- /dev/null
@@ -0,0 +1,13 @@
+<h1>Listing system_pictures</h1>
+
+<table>
+  <tr>
+    <th>Ext</th>
+  </tr>
+
+<% @authors.each do |author| %>
+  <tr>
+    <td><%= link_to h(author.name), :action => :show, :id => author.id %></td>
+  </tr>
+<% end %>
+</table>
diff --git a/app/views/authors/show.html.erb b/app/views/authors/show.html.erb
new file mode 100644 (file)
index 0000000..464be42
--- /dev/null
@@ -0,0 +1,8 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+  <b>name:</b>
+  <%= h(@author.name) %>
+</p>
+
+<%= link_to 'Back', :controller => 'authors' %>
index 849d93b..2032dec 100644 (file)
@@ -193,6 +193,7 @@ Pettanr::Application.routes.draw do
   match 'home/(:action)', :controller => 'home'
   match 'help/(:action)', :controller => 'help'
   match 'system/(:action)', :controller => 'system'
+  match 'authors/(:action(/:id))', :controller => 'authors'
 #  controller 'system' do
 #    get 'start'
 #    get 'index'
diff --git a/spec/controllers/authors_controller_spec.rb b/spec/controllers/authors_controller_spec.rb
new file mode 100644 (file)
index 0000000..c09f3d9
--- /dev/null
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe AuthorsController do
+
+end
diff --git a/spec/helpers/authors_helper_spec.rb b/spec/helpers/authors_helper_spec.rb
new file mode 100644 (file)
index 0000000..09acc33
--- /dev/null
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the AuthorsHelper. For example:
+#
+# describe AuthorsHelper do
+#   describe "string concat" do
+#     it "concats two strings with spaces" do
+#       helper.concat_strings("this","that").should == "this that"
+#     end
+#   end
+# end
+describe AuthorsHelper do
+  pending "add some examples to (or delete) #{__FILE__}"
+end