Permalink
Browse files

post enhancement -> user avatar in post field

  • Loading branch information...
1 parent fbb6617 commit db6e4e69ce7ce504fb180e7913df12ea8be5e13e Paweł Drożański committed Oct 24, 2012
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -7,3 +7,9 @@ li.avatar img {
margin-top: -5px;
line-height: 30px;
}
+img.avatar {
+ vertical-align: middle;
+ width: 50px;
+ margin-top: -5px;
+ line-height: 30px;
+}
@@ -1,9 +1,16 @@
class PostsController < ApplicationController
+ include ActionView::Helpers::DateHelper
+
# GET /posts
# GET /posts.json
def index
@posts = Post.all
+ #@user = session[:user_id]
+ @user = User.find(current_user.id).username
+
+ #@diff_date = distance_of_time_in_words(Time.now, Time.now + 3.minutes)
+
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
@@ -27,6 +34,8 @@ def new
@post = Post.new
#@post.update_attribute(:name, User.find_by_id(session[:user_id])).username
+ @post.update_attribute(:date, DateTime.now)
+
respond_to do |format|
format.html # new.html.erb
format.json { render json: @post }
@@ -1,2 +1,5 @@
module PostsHelper
+ def diff_date(date)
+ distance_of_time_in_words(Time.now, date)
+ end
end
@@ -3,8 +3,12 @@
.posts
- @posts.each do |post|
.post-box
+ = image_tag current_user.avatar_url, :class => "avatar"
+ = @user + ' shouts around!'
+ = post.date
%p= post.name
%p= post.content
+ -#%p= distance_of_time_in_words(Time.now, post.date)
-#%td= link_to 'Show', post
%td= link_to 'Edit', edit_post_path(post)
View
@@ -1,4 +1,12 @@
pl:
+ datetime:
+ distance_in_words:
+ x_minutes:
+ one: "1 minuta"
+ other: "%{count} minut"
+ x_hours:
+ one: "1 godzina"
+ other: "%{count} godzin"
activerecord:
attributes:
link:
@@ -0,0 +1,5 @@
+class AddDateToPost < ActiveRecord::Migration
+ def change
+ add_column :posts, :date, :datetime
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121023110640) do
+ActiveRecord::Schema.define(:version => 20121023133621) do
create_table "answers", :force => true do |t|
t.integer "question_id"
@@ -64,6 +64,7 @@
t.text "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.datetime "date"
end
create_table "projects", :force => true do |t|
View
0 script/rails 100755 → 100644
No changes.

0 comments on commit db6e4e6

Please sign in to comment.