Permalink
Browse files

comment

  • Loading branch information...
1 parent 3405de1 commit bb4bc293f3227958c9048e4e64ddb95f6bdd182f Ranja@web.de committed May 19, 2012
View
@@ -12,7 +12,7 @@ group :production do
gem 'pg'
end
-
+gem 'foreigner'
gem 'carrierwave'
View
@@ -43,6 +43,8 @@ GEM
erubis (2.7.0)
execjs (1.3.2)
multi_json (~> 1.0)
+ foreigner (1.1.6)
+ activerecord (>= 3.0.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
@@ -109,6 +111,7 @@ PLATFORMS
DEPENDENCIES
carrierwave
coffee-rails (~> 3.2.1)
+ foreigner
jquery-rails
pg
rails (= 3.2.3)
View
@@ -5,7 +5,14 @@ gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'sqlite3'
+group :development do
+ gem 'sqlite3'
+end
+group :production do
+ gem 'pg'
+end
+
+
gem 'carrierwave'
@@ -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/
@@ -11,3 +11,18 @@
*= require_self
*= require_tree .
*/
+
+#logo {
+ font-size: 20px;
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
+ float: left;
+ padding: 10px;
+}
+body { padding-top: 100px;background: #f00; }
+footer { margin-top: 100px; }
+table, td, th { vertical-align: middle !important; border: none !important; }
+th { border-bottom: 1px solid #DDD !important; }
+td.picture { width: 140px; }
+td.picture img { width: 140px; }
+
+
@@ -0,0 +1,3 @@
+// Place all the styles related to the comments controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,83 @@
+class CommentsController < ApplicationController
+ # GET /comments
+ # GET /comments.json
+ def index
+ @comments = Comment.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @comments }
+ end
+ end
+
+ # GET /comments/1
+ # GET /comments/1.json
+ def show
+ @comment = Comment.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/new
+ # GET /comments/new.json
+ def new
+ @comment = Comment.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/1/edit
+ def edit
+ @comment = Comment.find(params[:id])
+ end
+
+ # POST /comments
+ # POST /comments.json
+ def create
+ @comment = Comment.new(params[:comment])
+
+ respond_to do |format|
+ if @comment.save
+ format.html { redirect_to @comment.idea, notice: 'Comment was successfully created.' }
+ format.json { render json: @comment, status: :created, location: @comment }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /comments/1
+ # PUT /comments/1.json
+ def update
+ @comment = Comment.find(params[:id])
+
+ respond_to do |format|
+ if @comment.update_attributes(params[:comment])
+ format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /comments/1
+ # DELETE /comments/1.json
+ def destroy
+ @comment = Comment.find(params[:id])
+ @comment.destroy
+
+ respond_to do |format|
+ format.html { redirect_to comments_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -0,0 +1,83 @@
+class CommentsController < ApplicationController
+ # GET /comments
+ # GET /comments.json
+ def index
+ @comments = Comment.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @comments }
+ end
+ end
+
+ # GET /comments/1
+ # GET /comments/1.json
+ def show
+ @comment = Comment.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/new
+ # GET /comments/new.json
+ def new
+ @comment = Comment.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/1/edit
+ def edit
+ @comment = Comment.find(params[:id])
+ end
+
+ # POST /comments
+ # POST /comments.json
+ def create
+ @comment = Comment.new(params[:comment])
+
+ respond_to do |format|
+ if @comment.save
+ format.html { redirect_to @comment, notice: 'Comment was successfully created.' }
+ format.json { render json: @comment, status: :created, location: @comment }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /comments/1
+ # PUT /comments/1.json
+ def update
+ @comment = Comment.find(params[:id])
+
+ respond_to do |format|
+ if @comment.update_attributes(params[:comment])
+ format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /comments/1
+ # DELETE /comments/1.json
+ def destroy
+ @comment = Comment.find(params[:id])
+ @comment.destroy
+
+ respond_to do |format|
+ format.html { redirect_to comments_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -14,7 +14,7 @@ def index
# GET /ideas/1.json
def show
@idea = Idea.find(params[:id])
-
+ @comment = @idea.comments.new
respond_to do |format|
format.html # show.html.erb
format.json { render json: @idea }
@@ -0,0 +1,83 @@
+class IdeasController < ApplicationController
+ # GET /ideas
+ # GET /ideas.json
+ def index
+ @ideas = Idea.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @ideas }
+ end
+ end
+
+ # GET /ideas/1
+ # GET /ideas/1.json
+ def show
+ @idea = Idea.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @idea }
+ end
+ end
+
+ # GET /ideas/new
+ # GET /ideas/new.json
+ def new
+ @idea = Idea.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @idea }
+ end
+ end
+
+ # GET /ideas/1/edit
+ def edit
+ @idea = Idea.find(params[:id])
+ end
+
+ # POST /ideas
+ # POST /ideas.json
+ def create
+ @idea = Idea.new(params[:idea])
+
+ respond_to do |format|
+ if @idea.save
+ format.html { redirect_to @idea, notice: 'Idea was successfully created.' }
+ format.json { render json: @idea, status: :created, location: @idea }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @idea.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /ideas/1
+ # PUT /ideas/1.json
+ def update
+ @idea = Idea.find(params[:id])
+
+ respond_to do |format|
+ if @idea.update_attributes(params[:idea])
+ format.html { redirect_to @idea, notice: 'Idea was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @idea.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /ideas/1
+ # DELETE /ideas/1.json
+ def destroy
+ @idea = Idea.find(params[:id])
+ @idea.destroy
+
+ respond_to do |format|
+ format.html { redirect_to ideas_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module CommentsHelper
+end
View
@@ -0,0 +1,4 @@
+class Comment < ActiveRecord::Base
+ belongs_to :idea
+ attr_accessible :body, :idea_id, :user_name
+end
View
@@ -0,0 +1,3 @@
+class Comment < ActiveRecord::Base
+ belongs_to :idea attr_accessible :body, :idea_id, :user_name
+end
View
@@ -1,6 +1,8 @@
class Idea < ActiveRecord::Base
+has_many :comments
mount_uploader :picture, PictureUploader
+
attr_accessible :description, :name, :picture
end
View
@@ -1,5 +1,7 @@
class Idea < ActiveRecord::Base
+
+mount_uploader :picture, PictureUploader
attr_accessible :description, :name, :picture
end
-mount_uploader :picture, PictureUploader
+
@@ -0,0 +1,27 @@
+<%= form_for(@comment) do |f| %>
+ <% if @comment.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
+
+ <ul>
+ <% @comment.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :user_name %><br />
+ <%= f.text_field :user_name %>
+ </div>
+ <div class="field">
+ <%= f.label :body %><br />
+ <%= f.text_area :body %>
+ </div>
+<%= f.hidden_field :idea_id %>
+
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
Oops, something went wrong.

0 comments on commit bb4bc29

Please sign in to comment.