Skip to content

Commit cc95348

Browse files
committed
Merge pull request #75 from abhirao/rails3
Adding question creation, Q&A link on main page
2 parents 79c2707 + 0878cc7 commit cc95348

8 files changed

Lines changed: 55 additions & 16 deletions

File tree

Gemfile.lock

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,17 @@ GEM
149149
rake (0.9.2)
150150
rdoc (3.9.4)
151151
responders (0.6.4)
152-
rspec (2.6.0)
153-
rspec-core (~> 2.6.0)
154-
rspec-expectations (~> 2.6.0)
155-
rspec-mocks (~> 2.6.0)
156-
rspec-core (2.6.4)
157-
rspec-expectations (2.6.0)
158-
diff-lcs (~> 1.1.2)
159-
rspec-mocks (2.6.0)
160-
rspec-rails (2.6.1)
161-
actionpack (~> 3.0)
162-
activesupport (~> 3.0)
163-
railties (~> 3.0)
164-
rspec (~> 2.6.0)
152+
rspec (2.0.0.beta.19)
153+
rspec-core (= 2.0.0.beta.19)
154+
rspec-expectations (= 2.0.0.beta.19)
155+
rspec-mocks (= 2.0.0.beta.19)
156+
rspec-core (2.0.0.beta.19)
157+
rspec-expectations (2.0.0.beta.19)
158+
diff-lcs (>= 1.1.2)
159+
rspec-mocks (2.0.0.beta.19)
160+
rspec-rails (2.0.0.beta.19)
161+
rspec (= 2.0.0.beta.19)
162+
webrat (>= 0.7.2.beta.1)
165163
rubyzip (0.9.4)
166164
sass (3.1.7)
167165
sass-rails (3.1.0.rc.6)
@@ -197,6 +195,10 @@ GEM
197195
raindrops (~> 0.6)
198196
warden (1.0.5)
199197
rack (>= 1.0)
198+
webrat (0.7.3)
199+
nokogiri (>= 1.2.0)
200+
rack (>= 1.0)
201+
rack-test (>= 0.5.3)
200202
xpath (0.1.4)
201203
nokogiri (~> 1.3)
202204

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
// Place all the styles related to the Questions controller here.
22
// They will automatically be included in application.css.
33
// You can use Sass (SCSS) here: http://sass-lang.com/
4+
.flash{
5+
color: red;
6+
padding: 2px;
7+
font-size: 12x;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
class QuestionsController < InheritedController
2+
3+
def index
4+
@question = Question.new
5+
end
6+
7+
def create
8+
create!(:notice => "Question Asked!"){collection_url}
9+
end
210
end

app/views/layouts/application.html.haml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
= csrf_meta_tags
99
%body
1010
= render "shared/menu/user"
11-
= yield
11+
.flash #{flash[:notice]}
12+
= yield

app/views/questions/_form.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
= f.input :description
77

88
.actions
9-
= f.button :submit
9+
= f.button :submit , 'Ask Everyone'

app/views/questions/index.html.haml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
:javascript
2+
$(document).ready(function(){
3+
$('#ask_button').click(
4+
function(){
5+
$('#the_form').show();
6+
$('#ask_button').remove();
7+
});
8+
});
19
- content_for :title do
210
Questions
311

@@ -14,4 +22,8 @@
1422
%th
1523
%th
1624

17-
= render :partial => "list", :collection => collection
25+
= render :partial => "list", :collection => collection
26+
%div#the_form{:style=>'display:none'}
27+
= render "form"
28+
- if current_user
29+
%h3#ask_button Ask a question

app/views/static/root.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
%h1 Home!
2+
%a(href="/questions") Q&A

spec/views/root.html.haml_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'spec_helper'
2+
3+
describe "static/root" do
4+
5+
it "links to questions" do
6+
render
7+
rendered.should have_selector('a', :href => '/questions')
8+
end
9+
10+
end

0 commit comments

Comments
 (0)