Permalink
Browse files

Skip them bad words; view needs to be prettied up, but works nonetheless

  • Loading branch information...
Aditya Chadha
Aditya Chadha committed Apr 27, 2009
1 parent 3df55ca commit 76205002412bbc5aa1758a08500b313d93c19073
Showing with 61 additions and 81 deletions.
  1. +48 −45 app/controllers/badwords_controller.rb
  2. +13 −19 app/views/badwords/index.html.erb
  3. +0 −17 app/views/layouts/badwords.html.erb
@@ -1,8 +1,10 @@
class BadwordsController < ApplicationController
+ layout 'base'
# GET /badwords
# GET /badwords.xml
def index
@badwords = Badword.find(:all)
+ @badword = Badword.new
respond_to do |format|
format.html # index.html.erb
@@ -12,74 +14,75 @@ def index
# GET /badwords/1
# GET /badwords/1.xml
- def show
- @badword = Badword.find(params[:id])
+# def show
+# @badword = Badword.find(params[:id])
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @badword }
- end
- end
+# respond_to do |format|
+# format.html # show.html.erb
+# format.xml { render :xml => @badword }
+# end
+# end
- # GET /badwords/new
- # GET /badwords/new.xml
- def new
- @badword = Badword.new
+# # GET /badwords/new
+# # GET /badwords/new.xml
+# def new
+# @badword = Badword.new
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @badword }
- end
- end
+# respond_to do |format|
+# format.html # new.html.erb
+# format.xml { render :xml => @badword }
+# end
+# end
- # GET /badwords/1/edit
- def edit
- @badword = Badword.find(params[:id])
- end
+# # GET /badwords/1/edit
+# def edit
+# @badword = Badword.find(params[:id])
+# end
# POST /badwords
# POST /badwords.xml
def create
@badword = Badword.new(params[:badword])
+ @badword.phrase_id = -1
respond_to do |format|
if @badword.save
flash[:notice] = 'Badword was successfully created.'
- format.html { redirect_to(@badword) }
+ format.html { redirect_to(badwords_url) }
format.xml { render :xml => @badword, :status => :created, :location => @badword }
else
- format.html { render :action => "new" }
+ format.html { render :action => "index" }
format.xml { render :xml => @badword.errors, :status => :unprocessable_entity }
end
end
end
# PUT /badwords/1
# PUT /badwords/1.xml
- def update
- @badword = Badword.find(params[:id])
+# def update
+# @badword = Badword.find(params[:id])
- respond_to do |format|
- if @badword.update_attributes(params[:badword])
- flash[:notice] = 'Badword was successfully updated.'
- format.html { redirect_to(@badword) }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @badword.errors, :status => :unprocessable_entity }
- end
- end
- end
+# respond_to do |format|
+# if @badword.update_attributes(params[:badword])
+# flash[:notice] = 'Badword was successfully updated.'
+# format.html { redirect_to(@badword) }
+# format.xml { head :ok }
+# else
+# format.html { render :action => "edit" }
+# format.xml { render :xml => @badword.errors, :status => :unprocessable_entity }
+# end
+# end
+# end
- # DELETE /badwords/1
- # DELETE /badwords/1.xml
- def destroy
- @badword = Badword.find(params[:id])
- @badword.destroy
+# # DELETE /badwords/1
+# # DELETE /badwords/1.xml
+# def destroy
+# @badword = Badword.find(params[:id])
+# @badword.destroy
- respond_to do |format|
- format.html { redirect_to(badwords_url) }
- format.xml { head :ok }
- end
- end
+# respond_to do |format|
+# format.html { redirect_to(badwords_url) }
+# format.xml { head :ok }
+# end
+# end
end
@@ -1,19 +1,13 @@
-<h1>Listing badwords</h1>
-
-<table>
- <tr>
- </tr>
-
-<% for badword in @badwords %>
- <tr>
- <td><%= badword.term %></td>
- <td><%= link_to 'Show', badword %></td>
- <td><%= link_to 'Edit', edit_badword_path(badword) %></td>
- <td><%= link_to 'Destroy', badword, :confirm => 'Are you sure?', :method => :delete %></td>
- </tr>
-<% end %>
-</table>
-
-<br />
-
-<%= link_to 'New badword', new_badword_path %>
+<div class="intro info">
+ <h2>Stop words</h2>
+ <%- form_for(@badword) do |f| %>
+ <%= f.text_field :term, :value => "Skip word" %>
+ <%= f.submit 'Submit' %>
+ <%- end %>
+Currently Skipping:
+</div>
+<ul class="list">
+ <% for badword in @badwords %>
+ <li><%= badword.term %></li>
+ <% end %>
+</ul>
@@ -1,17 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
- <title>Badwords: <%= controller.action_name %></title>
- <%= stylesheet_link_tag 'scaffold' %>
-</head>
-<body>
-
-<p style="color: green"><%= flash[:notice] %></p>
-
-<%= yield %>
-
-</body>
-</html>

0 comments on commit 7620500

Please sign in to comment.