Created
September 14, 2012 16:53
-
-
Save telagraphic/3723210 to your computer and use it in GitHub Desktop.
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
<%= form_for([@day, @feed]) do |f| %> | |
<%= f.text_area :live_feed, :size => "34x13" %><br> | |
<%= f.submit %> | |
<% 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
<br> | |
<%= link_to "Back", day_path(@day) %><br> | |
<h1>Status...</h1> | |
<%= render "feed_form" %> | |
<h1>Live Feed</h1> | |
<% @feeds.each do |f| %> | |
<ul> | |
<li><%= f.live_feed %></li> | |
</ul> | |
<% 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 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]) | |
@feed = @day.feeds.build(params[:live_feed]) | |
if @feed.save | |
redirect_to day_feeds_path(@day) | |
else | |
render "index" | |
end | |
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 | |
has_many :feeds, :dependent => :destroy | |
belongs_to :user | |
end | |
class Feed < ActiveRecord::Base | |
belongs_to :day | |
attr_accessible :live_feed | |
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
Life::Application.routes.draw do | |
devise_for :users do | |
resources :days | |
end | |
root :to => "Days#index" | |
resources :days do | |
resources :habits | |
end | |
resources :days do | |
resources :feeds | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment