public
Description: A social application that helps members create, discover and enhance a remarkable or outstanding thing of its kind
Homepage: http://carlbtanner.com
Clone URL: git://github.com/captproton/palooza.git
Creating commments now works.  There's something screwy going on with the 
Comment resource, so I substituted the model AfterThought. So, here's what 
the user can currently do:

Register, log in, or log out as a user with supporting resource Profile.
CRUD Recipe with supporting models.
CRUD Comment for Recipe.
CRUD Asset.
CRUD Profile.
captproton (author)
Thu Jul 24 09:26:21 -0700 2008
commit  c0125bada5b3ee8d660bea1d6f97c068ed42bf68
tree    167df778b1330ac3736aa23c31694a35eec8d46a
parent  5f9ce7d2827b3f875009bd8f055758d7e78598b6
...
14
15
16
17
 
18
19
20
...
14
15
16
 
17
18
19
20
0
@@ -14,7 +14,7 @@ class RecipesController < ApplicationController
0
   # GET /recipes/1.xml
0
   def show
0
     @recipe = Recipe.find(params[:id])
0
- @comments = @recipe.comments
0
+ @comments = @recipe.after_thoughts.find(:all)
0
     @ingredients = @recipe.ingredients.find(:all)
0
     @food_categories = FoodCategory.find(:all)
0
     @newcomment = Comment.new
...
3
4
5
 
6
7
8
...
3
4
5
6
7
8
9
0
@@ -3,6 +3,7 @@ class SessionsController < ApplicationController
0
   # If you want "remember me" functionality, add this before_filter to Application Controller
0
   before_filter :login_from_cookie
0
 
0
+ layout "simple"
0
   def new
0
   end
0
   
...
4
5
6
 
 
 
 
7
8
9
...
4
5
6
7
8
9
10
11
12
13
0
@@ -4,6 +4,10 @@ module ApplicationHelper
0
     %(Good Food #{title})
0
     end
0
   
0
+ def page_classes
0
+ page_class = @page_classes ? "#{@page_classes}" : ''
0
+ %(class="#{page_class} ")
0
+ end
0
   
0
   # Show the local time
0
   def tz(time_at)
...
17
18
19
 
 
 
 
20
21
22
...
17
18
19
20
21
22
23
24
25
26
0
@@ -17,6 +17,10 @@ module RecipesHelper
0
         end
0
     end
0
     
0
+ def commenter_login(user_id)
0
+ User.find(user_id).login
0
+ end
0
+
0
     ##def cover_for(recipe, size = :medium)
0
     ## if recipe.cover
0
     ## cover_image = recipe.cover.public_filename(size)
...
1
2
 
3
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
 class Comment < ActiveRecord::Base
0
     belongs_to :recipe
0
+ belongs_to :user, :class_name => "User", :foreign_key => "user_id"
0
 end
...
1
2
3
4
 
5
6
7
...
14
15
16
 
17
18
19
...
1
2
3
 
4
5
6
7
...
14
15
16
17
18
19
20
0
@@ -1,7 +1,7 @@
0
 class Recipe < ActiveRecord::Base
0
     has_many :ingredients, :dependent => :destroy
0
     has_many :instructions, :dependent => :destroy
0
- has_many :comments, :dependent => :destroy
0
+ has_many :after_thoughts
0
     ## has_one :cover, :dependent => :destroy
0
     belongs_to :food_category
0
 
0
@@ -14,6 +14,7 @@ class Recipe < ActiveRecord::Base
0
 
0
     ## after_update :save_instructions
0
     after_update :save_ingredients
0
+ after_update :save_instructions
0
     
0
     def new_ingredient_attributes=(ingredient_attributes)
0
       ingredient_attributes.each do |attributes|
...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
0
@@ -4,18 +4,6 @@
0
   <%= f.error_messages %>
0
 
0
   <p>
0
- <%= f.label :recipe_id %><br />
0
- <%= f.text_field :recipe_id %>
0
- </p>
0
- <p>
0
- <%= f.label :body %><br />
0
- <%= f.text_field :body %>
0
- </p>
0
- <p>
0
- <%= f.label :user_id %><br />
0
- <%= f.text_field :user_id %>
0
- </p>
0
- <p>
0
     <%= f.submit "Update" %>
0
   </p>
0
 <% end %>
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
2
3
4
 
 
 
5
6
7
8
 
 
 
9
10
11
0
@@ -2,16 +2,10 @@
0
 
0
 <table>
0
   <tr>
0
- <th>Recipe</th>
0
- <th>Body</th>
0
- <th>User</th>
0
   </tr>
0
 
0
 <% for comment in @comments %>
0
   <tr>
0
- <td><%=h comment.recipe_id %></td>
0
- <td><%=h comment.body %></td>
0
- <td><%=h comment.user_id %></td>
0
     <td><%= link_to 'Show', comment %></td>
0
     <td><%= link_to 'Edit', edit_comment_path(comment) %></td>
0
     <td><%= link_to 'Destroy', comment, :confirm => 'Are you sure?', :method => :delete %></td>
...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
0
@@ -4,18 +4,6 @@
0
   <%= f.error_messages %>
0
 
0
   <p>
0
- <%= f.label :recipe_id %><br />
0
- <%= f.text_field :recipe_id %>
0
- </p>
0
- <p>
0
- <%= f.label :body %><br />
0
- <%= f.text_field :body %>
0
- </p>
0
- <p>
0
- <%= f.label :user_id %><br />
0
- <%= f.text_field :user_id %>
0
- </p>
0
- <p>
0
     <%= f.submit "Create" %>
0
   </p>
0
 <% end %>
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
0
@@ -1,18 +1,3 @@
0
-<p>
0
- <b>Recipe:</b>
0
- <%=h @comment.recipe_id %>
0
-</p>
0
-
0
-<p>
0
- <b>Body:</b>
0
- <%=h @comment.body %>
0
-</p>
0
-
0
-<p>
0
- <b>User:</b>
0
- <%=h @comment.user_id %>
0
-</p>
0
-
0
 
0
 <%= link_to 'Edit', edit_comment_path(@comment) %> |
0
 <%= link_to 'Back', comments_path %>
...
8
9
10
11
12
 
 
13
14
15
...
8
9
10
 
 
11
12
13
14
15
0
@@ -8,8 +8,8 @@
0
     <%= f.text_field :string %>
0
   </p>
0
   <p>
0
- <%= f.label :recipe_id %><br />
0
- <%= f.text_field :recipe_id %>
0
+ <%= f.label :item_id %><br />
0
+ <%= f.text_field :item_id %>
0
   </p>
0
   <p>
0
     <%= f.label :integer %><br />
...
30
31
32
33
34
 
 
35
 
 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
57
58
59
60
61
 
62
63
 
64
65
66
...
30
31
32
 
 
33
34
35
36
37
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
40
41
42
43
 
44
45
 
46
47
48
49
0
@@ -30,37 +30,20 @@
0
                   <a name="comments" id="comments"></a>
0
 
0
                   <div id="all-comments">
0
- <div id="comment-list"></div>
0
- </div>
0
+ <div id="comment_list">
0
+ <%= render :partial => 'recipes/show/comment', :collection => @comments %>
0
 
0
+ </div>
0
+ </div>
0
                   <div id="comments_reply">
0
- WHAT DO YOU THINK?
0
-
0
- <form action="/comments/new" method="post" onsubmit="new Ajax.Request('/comments/new', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">
0
- <input id="comment_item_type" name="comment[item_type]" type="hidden" value="Recipe" /> <input id="comment_item_id" name="comment[item_id]" type="hidden" value="12174" /> <input id="comment_user_id" name="comment[user_id]" type="hidden" value="207182" />
0
-
0
- <div id="comment-error" style="display:none" class="error_box">
0
- Please enter in a comment
0
- </div>
0
-
0
- <div id="reply_box">
0
- <textarea class="entry" cols="40" id="comment_body" name="comment[body]" rows="20">
0
-</textarea>
0
- </div><input class="button" name="commit" type="submit" value="Submit Comment" />
0
-
0
- <!-- div class="email_comments">
0
- Email me when there are new comments <input id="notify" name="notify" type="checkbox" value="1" />
0
- </div -->
0
- </form>
0
-
0
- <div class="clear"></div>
0
+ <%= render :partial => '/recipes/show/comments_reply_inner' %>
0
                   </div>
0
                 </div>
0
 
0
                 <div id="action_items_footer">
0
- <p>LIKE THIS RECIPE?</p><span id="save_item_3"><img alt="" src="http://www.chow.com/images/recipes/btn_fav_added.20080718171350.gif" /></span>
0
+ <p>LIKE THIS RECIPE?</p><span id="save_item_3"><img alt="" src="/images/recipes/btn_fav_added.gif" /></span>
0
 
0
- <div id="hidden_content_user_email_Recipe_12174" style="display: none;"></div><a class="email" href="#" onclick="new Ajax.Updater('hidden_content_user_email_Recipe_12174', '/user/email?item_id=12174&amp;item_type=Recipe', {asynchronous:true, evalScripts:true, onComplete:function(request){RedBox.addHiddenContent('hidden_content_user_email_Recipe_12174'); }, onLoading:function(request){RedBox.loading(); }}); return false;"><img alt="" onclick="new Effect.ScrollTo(&quot;bd&quot;, {offset: -200});" src="http://www.chow.com/images/recipes/btn_email.20080718171350.gif" title="Email this Recipe" /></a> <a href="/recipes/12174/hack"><img alt="Hack it" src="http://www.chow.com/images/recipes/btn_hack.20080718171350.gif" title="Create your own version of this recipe" /></a>
0
+ <div id="hidden_content_user_email_Recipe_12174" style="display: none;"></div><a class="email" href="#" onclick="new Ajax.Updater('hidden_content_user_email_Recipe_12174', '/user/email?item_id=12174&amp;item_type=Recipe', {asynchronous:true, evalScripts:true, onComplete:function(request){RedBox.addHiddenContent('hidden_content_user_email_Recipe_12174'); }, onLoading:function(request){RedBox.loading(); }}); return false;"><img alt="" onclick="new Effect.ScrollTo(&quot;bd&quot;, {offset: -200});" src="/images/recipes/btn_email.gif" title="Email this Recipe" /></a> <a href="/recipes/12174/hack"><img alt="Hack it" src="/images/recipes/btn_hack.gif" title="Create your own version of this recipe" /></a>
0
                 </div>
0
               </div><!--#col1b-->
0
 
...
 
 
1
...
1
2
3
0
@@ -1 +1,3 @@
0
+<% @page_title = "Access Denied!" %>
0
+<% @page_classes = "" %>
0
 <h1 style='color:red'>Access Denied!</h1>
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
0
@@ -1,34 +1,48 @@
0
-<style type="text/css">
0
-form {
0
- width: 49%;
0
- float: left;
0
-}
0
-</style>
0
-
0
- <% form_tag(sessions_path) do -%>
0
- <h2>Login</h2>
0
- <p><label for="login">Login</label>
0
- <%= text_field_tag 'login' %></p>
0
-
0
- <p><label for="password">Password</label>
0
- <%= password_field_tag 'password' %></p>
0
-
0
- <!-- Uncomment this if you want this functionality
0
- <p><label for="remember_me">Remember me:</label>
0
- <%= check_box_tag 'remember_me' %></p>
0
- -->
0
-
0
- <p><%= submit_tag 'Log in' %></p>
0
-
0
- <% end -%>
0
-
0
- <% form_for :user, :url => users_path do |f| -%>
0
-
0
- <h2>Sign up</h2>
0
-
0
- <%= f.error_messages %>
0
-
0
- <%= render :partial => 'users/form', :object => f %>
0
- <p><%= submit_tag 'Sign up' %></p>
0
-
0
- <% end #form_for -%>
0
+<% @page_title = "Login" %>
0
+<% @page_classes = "account_login account" %>
0
+
0
+ <div id="yui-main">
0
+ <div class="yui-b">
0
+ <script type="text/javascript">
0
+//<![CDATA[
0
+Event.observe(window, 'load', function() { $('login_name').focus() })
0
+//]]>
0
+</script>
0
+
0
+ <div class="content">
0
+ <h3 class="t_red">Members please sign in here:</h3>
0
+
0
+ <% form_tag(sessions_path) do -%>
0
+
0
+ <p class="form_row"><label for="name">Username:</label> <%= text_field_tag 'login' %></p>
0
+
0
+
0
+ <div class="clear"></div>
0
+
0
+ <p class="form_row"><label for="password">Password:</label> <%= password_field_tag 'password' %> <small><a href="/account/lost_password">Forgot your password?</a></small></p>
0
+
0
+ <div class="clear"></div><input class="button" name="commit" tabindex="4" type="submit" value="Log in" /> <input id="return_to" name="return_to" type="hidden" value="/stories/11211" />
0
+
0
+ <!-- Uncomment this if you want this functionality
0
+ <p><label for="remember_me">Remember me:</label>
0
+ <%= check_box_tag 'remember_me' %></p>
0
+ -->
0
+
0
+ <% end -%>
0
+
0
+ <% form_for :user, :url => users_path do |f| -%>
0
+
0
+ <h3 class="t_red">New users please register here:</h3>
0
+
0
+ <%= f.error_messages %>
0
+
0
+ <%= render :partial => 'users/form', :object => f %>
0
+ <p><%= submit_tag 'Sign up' %></p>
0
+
0
+ <% end #form_for -%>
0
+
0
+ </div>
0
+
0
+ <p>Not a member? <a href="/account/signup">Sign up today</a>.</p>
0
+ </div>
0
+ </div>
...
500
501
502
503
504
505
506
 
507
508
509
...
500
501
502
 
503
504
 
505
506
507
508
0
@@ -500,10 +500,9 @@ do_rbx_itrk_netxp1('rbx_netxp1_parent', 'rbx_netxp1_1', 'http://dw.com.com/rubic
0
             <li><%= link_to h(@user.real_name), user_path(@user) %></li>
0
             <li id="profile_nav_favorites" style="display: inline;">
0
               <%= link_to "Favorites", user_path(1) %>
0
- <a href="/account/combined?return_to=http%3A%2F%2Fwww.chow.com%2Fprofile%2Ffavorites">Favorites</a></li>
0
 
0
             <li id="profile_nav_settings" >
0
- <%= link_to h(current_user.login), user_path(current_user.login) %>
0
+ <%= link_to h(@user.login), user_path(@user.login) %>
0
             </li>
0
             <li id="profile_nav_newsletters"><a href="/newsletters">Newsletters</a></li>
0
             <% else %>
...
1
2
 
3
4
5
 
 
6
7
8
...
1
 
2
3
4
5
6
7
8
9
10
0
@@ -1,8 +1,10 @@
0
 ActionController::Routing::Routes.draw do |map|
0
- map.resources :profiles
0
+ map.resources :after_thoughts
0
 
0
   map.resources :comments
0
 
0
+ map.resources :profiles
0
+
0
   map.resources :cuisines
0
 
0
   map.resources :instructions
...
9
10
11
12
 
 
 
 
 
 
 
 
 
13
14
15
...
9
10
11
 
12
13
14
15
16
17
18
19
20
21
22
23
0
@@ -9,7 +9,15 @@
0
 #
0
 # It's strongly recommended to check this file into your version control system.
0
 
0
-ActiveRecord::Schema.define(:version => 20080719032708) do
0
+ActiveRecord::Schema.define(:version => 20080724065720) do
0
+
0
+ create_table "after_thoughts", :force => true do |t|
0
+ t.text "body"
0
+ t.datetime "created_at"
0
+ t.datetime "updated_at"
0
+ t.integer "recipe_id", :limit => 11
0
+ t.integer "user_id", :limit => 11
0
+ end
0
 
0
   create_table "assets", :force => true do |t|
0
     t.string "filename"
...
1
2
3
4
5
6
7
8
9
10
11
 
 
 
 
 
...
1
2
 
 
 
 
 
 
 
 
 
3
4
5
6
7
0
@@ -1,11 +1,7 @@
0
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
0
 
0
-one:
0
- recipe_id:
0
- body:
0
- user_id: 1
0
-
0
-two:
0
- recipe_id:
0
- body:
0
- user_id: 1
0
+# one:
0
+# column: value
0
+#
0
+# two:
0
+# column: value
...
3
4
5
6
7
8
9
10
11
...
3
4
5
 
 
 
6
7
8
0
@@ -3,9 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
0
 describe Comment do
0
   before(:each) do
0
     @valid_attributes = {
0
- :recipe_id => ,
0
- :body => ,
0
- :user_id => "1"
0
     }
0
   end
0
 
...
5
6
7
8
9
 
10
11
12
...
14
15
16
17
18
19
20
...
5
6
7
 
 
8
9
10
11
...
13
14
15
 
16
17
18
0
@@ -5,8 +5,7 @@ describe "/comments/edit.html.erb" do
0
   
0
   before(:each) do
0
     assigns[:comment] = @comment = stub_model(Comment,
0
- :new_record? => false,
0
- :body => ,
0
+ :new_record? => false
0
     )
0
   end
0
 
0
@@ -14,7 +13,6 @@ describe "/comments/edit.html.erb" do
0
     render "/comments/edit.html.erb"
0
     
0
     response.should have_tag("form[action=#{comment_path(@comment)}][method=post]") do
0
- with_tag('input#comment_body[name=?]', "comment[body]")
0
     end
0
   end
0
 end
...
5
6
7
8
9
10
11
12
13
 
 
14
15
16
17
18
19
20
21
22
...
5
6
7
 
 
 
 
 
 
8
9
10
11
12
13
14
 
15
16
17
0
@@ -5,18 +5,13 @@ describe "/comments/index.html.erb" do
0
   
0
   before(:each) do
0
     assigns[:comments] = [
0
- stub_model(Comment,
0
- :body => ,
0
- ),
0
- stub_model(Comment,
0
- :body => ,
0
- )
0
+ stub_model(Comment),
0
+ stub_model(Comment)
0
     ]
0
   end
0
 
0
   it "should render list of comments" do
0
     render "/comments/index.html.erb"
0
- response.should have_tag("tr>td", , 2)
0
   end
0
 end
0
 
...
5
6
7
8
9
 
10
11
12
...
14
15
16
17
18
19
20
...
5
6
7
 
 
8
9
10
11
...
13
14
15
 
16
17
18
0
@@ -5,8 +5,7 @@ describe "/comments/new.html.erb" do
0
   
0
   before(:each) do
0
     assigns[:comment] = stub_model(Comment,
0
- :new_record? => true,
0
- :body => ,
0
+ :new_record? => true
0
     )
0
   end
0
 
0
@@ -14,7 +13,6 @@ describe "/comments/new.html.erb" do
0
     render "/comments/new.html.erb"
0
     
0
     response.should have_tag("form[action=?][method=post]", comments_path) do
0
- with_tag("input#comment_body[name=?]", "comment[body]")
0
     end
0
   end
0
 end
...
4
5
6
7
8
9
 
10
11
12
13
14
15
16
17
...
4
5
6
 
 
 
7
8
9
10
11
 
12
13
14
0
@@ -4,14 +4,11 @@ describe "/comments/show.html.erb" do
0
   include CommentsHelper
0
   
0
   before(:each) do
0
- assigns[:comment] = @comment = stub_model(Comment,
0
- :body => ,
0
- )
0
+ assigns[:comment] = @comment = stub_model(Comment)
0
   end
0
 
0
   it "should render attributes in <p>" do
0
     render "/comments/show.html.erb"
0
- response.should have_text(//)
0
   end
0
 end
0
 

Comments

    No one has commented yet.