Permalink
Browse files

added discount to stories in #uindex #edit #add actions

  • Loading branch information...
1 parent 44cfe6e commit 8d02246361a772f9d49a402a6f06cbef885342ae @dziemian007 dziemian007 committed Jan 2, 2012
Showing with 8 additions and 4 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +2 −1 app/controllers/stories_controller.rb
  4. +2 −2 app/views/stories/show.html.erb
  5. +1 −1 app/views/stories/uindex.html.erb
View
@@ -13,6 +13,7 @@ gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
gem 'yaml_db'
gem 'date_validator'
gem 'twitter'
+gem 'rdiscount'
group :development do
gem 'rspec-rails', '2.6.1'
View
@@ -124,6 +124,7 @@ GEM
rake (0.9.2.2)
rake-compiler (0.7.9)
rake
+ rdiscount (1.6.8)
rdoc (3.12)
json (~> 1.4)
rspec (2.6.0)
@@ -197,6 +198,7 @@ DEPENDENCIES
mysql2
pg
rails (= 3.1.3)
+ rdiscount
rspec-rails (= 2.6.1)
sass-rails (~> 3.1.5)
sqlite3
@@ -64,6 +64,7 @@ def edit
def create
@story = Story.new(params[:story])
@title = "Nowy news"
+ @story.content = RDiscount.new(@story.content).to_html
respond_to do |format|
if @story.save
format.html { redirect_to @story, notice: 'Wiadomość utworzono pomyślnie.' }
@@ -80,7 +81,7 @@ def create
def update
@story = Story.find(params[:id])
@title = "Edycja newsa"
-
+ @story.content = RDiscount.new(@story.content).to_html
respond_to do |format|
if @story.update_attributes(params[:story])
format.html { redirect_to @story, notice: 'Wiadomość zapisano pomyślnie.' }
@@ -3,11 +3,11 @@
<h2><%= @story.title %></h2>
<p align="justify">
- <%= @story.teaser %>
+ <%= raw(@story.teaser) %>
</p>
<p align="justify">
- <%= @story.content %>
+ <%= raw(@story.content) %>
</p>
<p class="timestamp">
@@ -4,7 +4,7 @@
<tr><td>
<h3><%= link_to story.title, story %></h3>
<p align="justify">
- <%= story.teaser %>
+ <%= raw(story.teaser) %>
</p>
<p class="timestamp">dodano <%= story.created_at.strftime("%Y-%m-%d %H:%M") %></p>
</td></tr>

0 comments on commit 8d02246

Please sign in to comment.