Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

render latest questions on index page

Signed-off-by: David A. Cuadrado <krawek@gmail.com>
  • Loading branch information...
commit 2724fc5acd688447367c259d1ecf77f75c18b1f9 1 parent 3e88767
David Cuadrado dcu authored
1  app/controllers/welcome_controller.rb
... ... @@ -1,4 +1,5 @@
1 1 class WelcomeController < ApplicationController
2 2 def index
  3 + @questions = Question.paginate(:per_page => 25, :page => params[:page] || 1, :limit => 20, :conditions => {:answered => false})
3 4 end
4 5 end
8 app/models/question.rb
... ... @@ -1,12 +1,12 @@
1 1 class Question
2 2 include MongoMapper::Document
3 3
4   - key :title, String
5   - key :body, String
6   - key :answered, Boolean
  4 + key :title, String, :required => true
  5 + key :body, String, :required => true
  6 + key :answered, Boolean, :default => false
7 7
8 8 belongs_to :user
9 9
10   - validates_presence_of :user_id, :body, :title
  10 + validates_presence_of :user_id
11 11 end
12 12
6 app/views/layouts/application.html.haml
@@ -54,9 +54,9 @@
54 54 %li
55 55 =link_to "tags", "#"
56 56 %li
57   - =link_to "users", "#"
  57 + =link_to "users", users_path
58 58 %li
59   - =link_to "questions", "#"
  59 + =link_to "unanswered", "#"
60 60 %li{:style=>"float: right;"}
61 61 =link_to "ask question", new_question_path, :style => "background: #B5CBE6"
62 62 #main-content
@@ -75,4 +75,4 @@
75 75 #footer
76 76 %hr
77 77 %p
78   - \&copy; 2009 Ricodigo. All rights reserved.
  78 + \&copy; 2009 Ricodigo. Some rights reserved.
18 app/views/welcome/index.html.haml
@@ -2,15 +2,9 @@
2 2 %h1
3 3 Welcome#index
4 4
5   -%span.clear
6   -%p
7   - Find me in app/views/welcome/index.html.erb
8   -
9   --if logged_in?
10   - Logged in as:
11   - = h(current_user.login)
12   -
13   -%p
14   - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam quis iaculis justo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras consectetur ullamcorper gravida. Proin vitae porttitor ligula. Mauris ultricies sapien eu tellus tempus eu vehicula magna tristique. Pellentesque ac nisl nisl. Duis bibendum consequat porta. In nec justo magna, at feugiat lectus. Curabitur malesuada, diam vitae tincidunt aliquet, eros elit elementum arcu, ac euismod metus massa non quam. Nunc fringilla, leo ac venenatis hendrerit, nibh massa adipiscing diam, ut gravida tortor justo at quam. Morbi in suscipit tortor. Cras aliquam pretium metus, vel congue tellus mattis eu. Curabitur scelerisque volutpat mauris, eu malesuada dolor tempus eu. Vestibulum ac ante velit, consectetur mollis quam. Maecenas sagittis elit nisl, eget pellentesque justo. Aenean varius, risus vitae viverra lobortis, nulla orci vestibulum lectus, nec pretium mauris velit sit amet felis. Sed placerat dolor sit amet enim hendrerit imperdiet eget et arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
15   -
16   - Vivamus hendrerit, augue sed vehicula consectetur, libero neque faucibus magna, sed interdum odio nisl ut risus. Integer ac augue odio. Morbi vel nulla elit, ac cursus dolor. Suspendisse ullamcorper urna ac erat condimentum mattis. Quisque aliquam vestibulum varius. Aliquam venenatis ultricies semper. Duis dignissim, nisl quis dapibus faucibus, magna mauris pellentesque metus, quis dignissim nibh nunc non elit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer in nulla erat, sed porta ante. Morbi nunc mi, tempor eu ullamcorper dignissim, tempus non ligula. Morbi viverra metus a tellus placerat laoreet molestie in lacus. Sed vitae tincidunt ligula. Integer ornare ante volutpat erat dictum euismod. Donec orci leo, consequat dictum cursus vitae, lobortis nec metus. Etiam erat est, pulvinar id pellentesque sit amet, pulvinar eu sapien. Nulla pulvinar tempus vehicula. Integer quis mi purus, quis venenatis erat. Ut nec venenatis ante. Etiam quis vulputate leo. Sed condimentum, quam sed faucibus dictum, velit lacus porta felis, eget dapibus quam quam eu orci.
  5 +%ul
  6 + -@questions.each do |question|
  7 + %li
  8 + %strong
  9 + = question.title
  10 + = truncate(question.body, :lenght => 200)
1  tmp/.gitignore
... ... @@ -0,0 +1 @@
  1 +sass-cache

0 comments on commit 2724fc5

Please sign in to comment.
Something went wrong with that request. Please try again.