This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="comments"> | |
<h2>Post A Comment</h2> | |
<%= form_for([@post, @comment]) do |comment| %> | |
<%= comment.label :email %><br/> | |
<%= comment.text_field :email %><br/> | |
<%= comment.label :body %><br/> | |
<%= comment.text_area :body, :size => "60x12" %><br/> | |
<%= comment.submit "Shout out" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>What Others Are Saying...</h2> | |
<% @comments.each do |comment| %> | |
<li><%= comment.email %></li> | |
<li><%= comment.body %></li> | |
<% end %> | |
<hr> | |
<%= render "comments/comment_form" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if user_signed_in? %> | |
<%= link_to "New Post", new_post_path %> | |
<% end %> | |
<article class="post"> | |
<% @posts.each do |post| %> | |
<h1><%= link_to post.title, post %></h1> | |
<h4> Posted <a href="#"><July 13, 2012><%= post.created_at.strftime("%d %b. %Y") %></a> </h4> | |
<h5><%= @comments.count %></h5> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
before_filter :get_post | |
def get_post | |
@post = Post.find(params[:post_id]) # comment model has this table, so why are we calling it on post db? | |
end | |
def create | |
@comment = @post.comments.new(params[:comment]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Action < ActiveRecord::Base | |
belongs_to :day | |
attr_accessible :energy, :mood, :overall | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No route matches {:action=>"show", :controller=>"habits", :day_id=>#<Day id: 4, wake: "7:30 am", sleep: "", created_at: "2012-09-09 20:11:48", updated_at: "2012-09-09 20:11:48">, :id=>nil} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Life::Application.routes.draw do | |
root :to => "Days#index" | |
resources :days do | |
resources :habits | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Day < ActiveRecord::Base | |
attr_accessible :sleep, :wake | |
has_one :habit, :dependent => :destroy | |
belongs_to :user | |
end | |
class Habit < ActiveRecord::Base | |
belongs_to :day | |
attr_accessible :energy, :mood, :overall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FeedsController < ApplicationController | |
def index | |
@day = Day.find(params[:day_id]) | |
@feed = @day.feeds.build # build association object | |
@feeds = @day.feeds.all # list all feed submits | |
end | |
def create | |
@day = Day.find(params[:day_id]) |
OlderNewer