Rails, how to get rid of html tags in my page? -
Rails, how to get rid of html tags in my page? -
this .rb code under app/db/migrate folder
#--- # excerpted "agile web development rails, 3rd ed.", # published pragmatic bookshelf. # copyrights apply code. may not used create training material, # courses, books, articles, , like. contact if in doubt. # create no guarantees code fit purpose. # visit http://www.pragmaticprogrammer.com/titles/rails3 more book information. #--- class addtestdata < activerecord::migration def self.up product.delete_all product.create(:title => 'pragmatic project automation', :description => %{<p> <em>pragmatic project automation</em> shows how improve consistency , repeatability of project's procedures using automation cut down risk , errors. </p> <p> put, we're going set thing called computer work doing mundane (but important) project stuff. means you'll have more time , energy exciting---and difficult---stuff, writing quality code. </p>}, :image_url => '/images/auto.jpg', :price => 29.95) product.create(:title => 'pragmatic version control', :description => %{<p> book recipe-based approach using subversion , running quickly---and correctly. projects need version control: it's foundational piece of project's infrastructure. yet half of project teams in u.s. don't utilize version command @ all. many others don't utilize well, , end experiencing time-consuming problems. </p>}, :image_url => '/images/svn.jpg', :price => 28.50) # . . . product.create(:title => 'pragmatic unit testing (c#)', :description => %{<p> pragmatic programmers utilize feedback drive development , personal processes. valuable feedback can while coding comes unit testing. </p> <p> without tests in place, coding can become frustrating game of "whack-a-mole." that's carnival game player strikes @ mechanical mole; retreats , mole pops on opposite side of field. moles pop , downwards fast end flailing mallet helplessly moles go on pop to the lowest degree expect them. </p>}, :image_url => '/images/utc.jpg', :price => 27.75) end def self.down product.delete_all end end
when show "description" in later page.
<h1>your pragmatic catalog</h1> <% product in @products -%> <div class="entry"> <%= image_tag(product.image_url) %> <h3><%= product.title %></h3> <%= product.description %> <div class="price-line"> <span class="price"><%= product.price %></span> </div> </div> <% end %>
the whole text begin <p>
, end </p>
. why? how can rid of these html tag? tried delete <p></p>
in .rb code. it's not working. new ror. please help.
instead of product.description
utilize simple_format(product.description)
rid of html tags.
ruby-on-rails
Comments
Post a Comment