Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

question and answer framework added

  • Loading branch information...
commit 50030bf662651d33cdbb8232220928233595706d 1 parent c7784e0
Karthikeyan A K authored
View
BIN  .redcar/lucene/_4g_1.del
Binary file not shown
View
BIN  .redcar/lucene/_4h.cfs
Binary file not shown
View
BIN  .redcar/lucene/_4h_1.del
Binary file not shown
View
BIN  .redcar/lucene/_4i.cfs
Binary file not shown
View
BIN  .redcar/lucene/_4j.cfs
Binary file not shown
View
BIN  .redcar/lucene/_4g.cfs → .redcar/lucene/_6y.cfs
Binary file not shown
View
BIN  .redcar/lucene/_6y_1.del
Binary file not shown
View
BIN  .redcar/lucene/_6z.cfs
Binary file not shown
View
0  .redcar/lucene/_4i_1.del → .redcar/lucene/_6z_1.del
File renamed without changes
View
BIN  .redcar/lucene/_70.cfs
Binary file not shown
View
BIN  .redcar/lucene/segments.gen
Binary file not shown
View
BIN  .redcar/lucene/segments_45 → .redcar/lucene/segments_6d
Binary file not shown
View
2  .redcar/lucene_last_updated
@@ -1 +1 @@
-1333448454
+1333469567
View
2  .redcar/redcar.lock
@@ -1 +1 @@
-2591: Locked by 2591 at Tue Apr 03 11:22:04 +0530 2012
+5605: Locked by 5605 at Tue Apr 03 19:25:58 +0530 2012
View
39 .redcar/storage/cursor_saver.yaml
@@ -3,9 +3,6 @@ cursor_positions:
- :path: app/assets/stylesheets/scaffolds.css.scss
:cursor_offset: 811
:timestamp: 2012-04-03 13:21:44 +05:30
- - :path: app/views/questions/show.html.erb
- :cursor_offset: 392
- :timestamp: 2012-04-03 14:51:40 +05:30
- :path: config/routes.rb
:cursor_offset: 80
:timestamp: 2012-04-03 13:13:02 +05:30
@@ -15,20 +12,9 @@ cursor_positions:
- :path: app/views/questions/new.html.erb
:cursor_offset: 0
:timestamp: 2012-04-03 11:08:19 +05:30
- - :path: app/views/questions/_form.html.erb
- :cursor_offset: 64
- :timestamp: 2012-04-03 13:23:52 +05:30
- :selection_offset: 24
- :block_selection_mode: false
- - :path: app/models/answer.rb
- :cursor_offset: 73
- :timestamp: 2012-04-03 12:29:20 +05:30
- :path: app/views/answers/_answer.html.haml
:cursor_offset: 28
:timestamp: 2012-04-03 14:48:53 +05:30
- - :path: app/models/question.rb
- :cursor_offset: 166
- :timestamp: 2012-04-03 14:50:13 +05:30
- :path: db/migrate/20120403065515_create_answers.rb
:cursor_offset: 91
:timestamp: 2012-04-03 12:25:15 +05:30
@@ -41,10 +27,29 @@ cursor_positions:
- :path: app/views/questions/_question.html.haml
:cursor_offset: 327
:timestamp: 2012-04-03 12:12:16 +05:30
- - :path: app/controllers/questions_controller.rb
- :cursor_offset: 364
- :timestamp: 2012-04-03 11:44:44 +05:30
- :path: Gemfile
:cursor_offset: 503
:timestamp: 2012-04-02 20:49:13 +05:30
+ - :path: app/views/questions/show.html.erb
+ :cursor_offset: 325
+ :timestamp: 2012-04-03 15:09:27 +05:30
+ - :path: app/views/questions/_form.html.erb
+ :cursor_offset: 666
+ :timestamp: 2012-04-03 13:23:52 +05:30
+ :selection_offset: 625
+ :block_selection_mode: false
+ - :path: app/models/question.rb
+ :cursor_offset: 38
+ :timestamp: 2012-04-03 14:50:13 +05:30
+ :selection_offset: 117
+ :block_selection_mode: false
+ - :path: app/models/answer.rb
+ :cursor_offset: 91
+ :timestamp: 2012-04-03 15:05:31 +05:30
+ - :path: app/controllers/answers_controller.rb
+ :cursor_offset: 67
+ :timestamp: 2012-04-03 19:36:45 +05:30
+ - :path: app/controllers/questions_controller.rb
+ :cursor_offset: 364
+ :timestamp: 2012-04-03 11:44:44 +05:30
files_to_retain: 0
View
7 .redcar/storage/project_loader.yaml
@@ -1,3 +1,8 @@
---
open_files:
- - Gemfile
+ - app/views/questions/_form.html.erb
+ - app/views/questions/show.html.erb
+ - app/models/question.rb
+ - app/models/answer.rb
+ - app/controllers/answers_controller.rb
+ - app/controllers/questions_controller.rb
View
2  .redcar/storage/sessions.yaml
@@ -4,4 +4,4 @@ bounds:
y: 24
width: 1282
height: 806
-tree_width: 205
+tree_width: 266
View
6 .redcar/tags
@@ -1,4 +1,4 @@
-1333448454
+1333469567
Answer /home/karthikeyan/qua/app/models/answer.rb class Answer
AnswerTest /home/karthikeyan/qua/test/unit/answer_test.rb class AnswerTest
AnswersController /home/karthikeyan/qua/app/controllers/answers_controller.rb class AnswersController
@@ -24,9 +24,13 @@ change /home/karthikeyan/qua/db/migrate/20120403065515_create_answers.rb def c
create /home/karthikeyan/qua/app/controllers/questions_controller.rb def create
create /home/karthikeyan/qua/app/controllers/answers_controller.rb def create
destroy /home/karthikeyan/qua/app/controllers/questions_controller.rb def destroy
+destroy /home/karthikeyan/qua/app/controllers/answers_controller.rb def destroy
edit /home/karthikeyan/qua/app/controllers/questions_controller.rb def edit
+edit /home/karthikeyan/qua/app/controllers/answers_controller.rb def edit
+find_qua /home/karthikeyan/qua/app/controllers/answers_controller.rb def find_qua
index /home/karthikeyan/qua/app/controllers/questions_controller.rb def index
new /home/karthikeyan/qua/app/controllers/questions_controller.rb def new
show /home/karthikeyan/qua/app/controllers/questions_controller.rb def show
test_homepage /home/karthikeyan/qua/test/performance/browsing_test.rb def test_homepage
update /home/karthikeyan/qua/app/controllers/questions_controller.rb def update
+update /home/karthikeyan/qua/app/controllers/answers_controller.rb def update
View
5 README.md
@@ -0,0 +1,5 @@
+== Qua
+
+Qua is a question and answer system like stack overflow. I developed it because I don't like the way stak treated me. All I want to do is to ask questions and get answers,thats it, but stack put in a lot of rules,gave mestuff like badges and blah blah which was totally unnecessary. So I am creating a question and answer system that does what I want.
+
+This software will be available as free software, released under GPLV3 Licence. I use Ruby on Rails 3.2.1 to write this software.
View
261 README.rdoc
@@ -1,261 +0,0 @@
-== Welcome to Rails
-
-Rails is a web-application framework that includes everything needed to create
-database-backed web applications according to the Model-View-Control pattern.
-
-This pattern splits the view (also called the presentation) into "dumb"
-templates that are primarily responsible for inserting pre-built data in between
-HTML tags. The model contains the "smart" domain objects (such as Account,
-Product, Person, Post) that holds all the business logic and knows how to
-persist themselves to a database. The controller handles the incoming requests
-(such as Save New Account, Update Product, Show Post) by manipulating the model
-and directing data to the view.
-
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in
-link:files/vendor/rails/activerecord/README.html.
-
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in
-link:files/vendor/rails/actionpack/README.html.
-
-
-== Getting Started
-
-1. At the command prompt, create a new Rails application:
- <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
-
-2. Change directory to <tt>myapp</tt> and start the web server:
- <tt>cd myapp; rails server</tt> (run with --help for options)
-
-3. Go to http://localhost:3000/ and you'll see:
- "Welcome aboard: You're riding Ruby on Rails!"
-
-4. Follow the guidelines to start developing your application. You can find
-the following resources handy:
-
-* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
-* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
-
-
-== Debugging Rails
-
-Sometimes your application goes wrong. Fortunately there are a lot of tools that
-will help you debug it and get it back on the rails.
-
-First area to check is the application log files. Have "tail -f" commands
-running on the server.log and development.log. Rails will automatically display
-debugging and runtime information to these files. Debugging info will also be
-shown in the browser on requests from 127.0.0.1.
-
-You can also log your own messages directly into the log file from your code
-using the Ruby logger class from inside your controllers. Example:
-
- class WeblogController < ActionController::Base
- def destroy
- @weblog = Weblog.find(params[:id])
- @weblog.destroy
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
- end
- end
-
-The result will be a message in your log file along the lines of:
-
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
-
-More information on how to use the logger is at http://www.ruby-doc.org/core/
-
-Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
-several books available online as well:
-
-* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
-* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
-
-These two books will bring you up to speed on the Ruby language and also on
-programming in general.
-
-
-== Debugger
-
-Debugger support is available through the debugger command when you start your
-Mongrel or WEBrick server with --debugger. This means that you can break out of
-execution at any point in the code, investigate and change the model, and then,
-resume execution! You need to install ruby-debug to run the server in debugging
-mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
-
- class WeblogController < ActionController::Base
- def index
- @posts = Post.all
- debugger
- end
- end
-
-So the controller will accept the action, run the first line, then present you
-with a IRB prompt in the server window. Here you can do things like:
-
- >> @posts.inspect
- => "[#<Post:0x14a6be8
- @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
- #<Post:0x14a6620
- @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
- >> @posts.first.title = "hello from a debugger"
- => "hello from a debugger"
-
-...and even better, you can examine how your runtime objects actually work:
-
- >> f = @posts.first
- => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
- >> f.
- Display all 152 possibilities? (y or n)
-
-Finally, when you're ready to resume execution, you can enter "cont".
-
-
-== Console
-
-The console is a Ruby shell, which allows you to interact with your
-application's domain model. Here you'll have all parts of the application
-configured, just like it is when the application is running. You can inspect
-domain models, change values, and save to the database. Starting the script
-without arguments will launch it in the development environment.
-
-To start the console, run <tt>rails console</tt> from the application
-directory.
-
-Options:
-
-* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
- made to the database.
-* Passing an environment name as an argument will load the corresponding
- environment. Example: <tt>rails console production</tt>.
-
-To reload your controllers and models after launching the console run
-<tt>reload!</tt>
-
-More information about irb can be found at:
-link:http://www.rubycentral.org/pickaxe/irb.html
-
-
-== dbconsole
-
-You can go to the command line of your database directly through <tt>rails
-dbconsole</tt>. You would be connected to the database with the credentials
-defined in database.yml. Starting the script without arguments will connect you
-to the development database. Passing an argument will connect you to a different
-database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
-PostgreSQL and SQLite 3.
-
-== Description of Contents
-
-The default directory structure of a generated Ruby on Rails application:
-
- |-- app
- | |-- assets
- | |-- images
- | |-- javascripts
- | `-- stylesheets
- | |-- controllers
- | |-- helpers
- | |-- mailers
- | |-- models
- | `-- views
- | `-- layouts
- |-- config
- | |-- environments
- | |-- initializers
- | `-- locales
- |-- db
- |-- doc
- |-- lib
- | `-- tasks
- |-- log
- |-- public
- |-- script
- |-- test
- | |-- fixtures
- | |-- functional
- | |-- integration
- | |-- performance
- | `-- unit
- |-- tmp
- | |-- cache
- | |-- pids
- | |-- sessions
- | `-- sockets
- `-- vendor
- |-- assets
- `-- stylesheets
- `-- plugins
-
-app
- Holds all the code that's specific to this particular application.
-
-app/assets
- Contains subdirectories for images, stylesheets, and JavaScript files.
-
-app/controllers
- Holds controllers that should be named like weblogs_controller.rb for
- automated URL mapping. All controllers should descend from
- ApplicationController which itself descends from ActionController::Base.
-
-app/models
- Holds models that should be named like post.rb. Models descend from
- ActiveRecord::Base by default.
-
-app/views
- Holds the template files for the view that should be named like
- weblogs/index.html.erb for the WeblogsController#index action. All views use
- eRuby syntax by default.
-
-app/views/layouts
- Holds the template files for layouts to be used with views. This models the
- common header/footer method of wrapping views. In your views, define a layout
- using the <tt>layout :default</tt> and create a file named default.html.erb.
- Inside default.html.erb, call <% yield %> to render the view using this
- layout.
-
-app/helpers
- Holds view helpers that should be named like weblogs_helper.rb. These are
- generated for you automatically when using generators for controllers.
- Helpers can be used to wrap functionality for your views into methods.
-
-config
- Configuration files for the Rails environment, the routing map, the database,
- and other dependencies.
-
-db
- Contains the database schema in schema.rb. db/migrate contains all the
- sequence of Migrations for your schema.
-
-doc
- This directory is where your application documentation will be stored when
- generated using <tt>rake doc:app</tt>
-
-lib
- Application specific libraries. Basically, any kind of custom code that
- doesn't belong under controllers, models, or helpers. This directory is in
- the load path.
-
-public
- The directory available for the web server. Also contains the dispatchers and the
- default HTML files. This should be set as the DOCUMENT_ROOT of your web
- server.
-
-script
- Helper scripts for automation and generation.
-
-test
- Unit and functional tests along with fixtures. When using the rails generate
- command, template test files will be generated for you and placed in this
- directory.
-
-vendor
- External libraries that the application depends on. Also includes the plugins
- subdirectory. If the app has frozen rails, those gems also go here, under
- vendor/rails/. This directory is in the load path.
View
13 app/assets/stylesheets/questions.css.scss
@@ -2,7 +2,7 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
-div.question{
+div.question, div.answer{
margin-top: 2em;
margin-bottom: 2em;
@@ -19,4 +19,13 @@ div.question{
textarea.big-width{
width: 80%;
-}
+}
+
+$heaing_color: #999999;
+
+h1.grey-heading{
+ color: $heaing_color;
+ font-size: 16pt;
+ padding-bottom: 3px;
+ border-bottom: $heaing_color 2px dotted;
+}
View
28 app/controllers/answers_controller.rb
@@ -1,7 +1,35 @@
class AnswersController < ApplicationController
+ layout 'questions'
+ before_filter :find_qua, :except=>[:create]
def create
@question = Question.find(params[:question_id])
@answer = @question.answers.create(params[:answer])
redirect_to question_path(@question)
end
+
+ def destroy
+ @question = Question.find(params[:question_id])
+ @answer = @question.answers.find(params[:id])
+ @answer.destroy
+ redirect_to @question, notice: "Answer Deleted"
+ end
+
+ def edit
+ @question = Question.find(params[:question_id])
+ @answer = @question.answers.find(params[:id])
+ end
+
+ def update
+ @question = Question.find(params[:question_id])
+ @answer = @question.answers.find(params[:id])
+ @answer.update_attributes params[:answer]
+ @answer.save
+ redirect_to @question, notice: "Answer Updated"
+ end
+
+ private
+ def find_qua
+ @question = Question.find(params[:question_id])
+ @answer = @question.answers.find(params[:id])
+ end
end
View
5 app/views/answers/_answer.html.haml
@@ -1,2 +1,5 @@
.answer
- %p= answer.content
+ %p= answer.content
+ %p
+ = link_to "Edit", edit_question_answer_path(answer.question, answer), class: "btn btn-warning btn-mini"
+ = link_to "Delete", question_answer_path(answer.question, answer), method: :delete, class:"btn btn-danger btn-mini", confirm: "Do you really want to delete this Answer?"
View
9 app/views/answers/edit.html.haml
@@ -0,0 +1,9 @@
+= form_for([@question, @answer], :html=>{:class => "form-horizontal"}) do |f|
+ %fieldset
+ %legend= "Edit Article"
+ .control-group
+ = f.label :content, "Answer", class: "control-label"
+ .controls
+ = f.text_area :content, class: 'text_area big-width', rows: 15
+ .form-actions
+ = f.submit "Edit Comment", class: "btn btn-primary"
View
8 app/views/layouts/questions.html.erb
@@ -55,6 +55,14 @@
</div><!--/.well -->
</div><!--/span-->
<div class="span9">
+ <% if notice %>
+ <div class="alert fade in">
+ <a href="#" data-dismiss="alert" class="close">×</a>
+ <ul>
+ <%= raw notice %>
+ </ul>
+ </div>
+ <% end %>
<%= yield %>
</div>
</div><!--/row-->
View
17 app/views/questions/show.html.erb
@@ -1,13 +1,14 @@
-<p>
- <%= @question.content %>
-</p>
-
-<div>
- <%= link_to 'Back', questions_path, :class => 'btn btn-mini' %>
- <%= link_to 'Edit', edit_question_path(@question), :class => 'btn btn-mini' %>
- <%= link_to 'Delete', question_path(@question), :method => 'delete', :confirm => 'Are you sure?', :class => 'btn btn-danger btn-mini' %>
+<h1 class="grey-heading">Question</h1>
+<div class="question">
+ <p><%= @question.content %></p>
+ <div class="action">
+ <%= link_to 'Back', questions_path, :class => 'btn btn-mini' %>
+ <%= link_to 'Edit', edit_question_path(@question), :class => 'btn btn-mini' %>
+ <%= link_to 'Delete', question_path(@question), :method => 'delete', :confirm => 'Are you sure?', :class => 'btn btn-danger btn-mini' %>
+ </div>
</div>
+<h1 class="grey-heading">Answers</h1>
<%= render @question.answers %>
<%= form_for([@question, @question.answers.build], :html => { :class => 'form-horizontal' }) do |f| %>
Please sign in to comment.
Something went wrong with that request. Please try again.