Skip to content

Instantly share code, notes, and snippets.

@soilforlifeforms
Created June 18, 2015 10:19
Show Gist options
  • Select an option

  • Save soilforlifeforms/c23e4bb44442897b9068 to your computer and use it in GitHub Desktop.

Select an option

Save soilforlifeforms/c23e4bb44442897b9068 to your computer and use it in GitHub Desktop.
<section id="about" class="about-section section">
<div class="container">
<h2 class="section-heading text-center">All posts</h2>
<div class="about-row row">
<p> It’s that awesome time of the year again where we at Soil for Life are hosting our yearly Eat for the Earth campaign. And we invite people and organizations all over the world to do the same and support the amazing work we are doing. We are particularly excited this year because 2015 is the Year of the Soil and soil is our favourite thing! We are so keen, in fact, that we have started this BLOG, that’s right a whole blog! Keep your eyes on this space for awesome tidbits and suggestions about how to build the soil, look after the earth and prepare healthy, delicious meals. </p>
<ul id="posts">
<% @posts.each do |f| %>
<li>
<%= link_to f.title, posts_path(f) %>
</li> <p> Comments (<%= f.comments.size %>) </p>
<%= truncate f.body, length: 300 %>
<% end %>
</div>
</div>
</section>
<div class="closing-buttons" > <a href="http://www.soilforlife.co.za" class="anchor-link btn btn-lg btn-primary">More about Soil For Life</a> </div>
</div>
</div>
</div>
</section>
class PostsController < ApplicationController
include PostsHelper
before_action :authenticate_user!
def index
@posts = Post.all
#@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def show
@post = Post.find(params[:id])
@comment = Comment.new
@comment.post_id = @post.id
#redirect_to post_path(@comment.post)
# @coment.user = current_user.id
end
def create
@post = Post.new(post_params)
@post.save
redirect_to post_path(@post)
end
def edit
@post = Post.find(params[:id])
end
def update
@post = Post.find(params[:id])
@post.update(post_params)
flash.notice = "Post '#{@post.title}' Updated!"
redirect_to post_path(@post)
end
def destroy
@post = Post.find(params[:id])
@post.destroy
redirect_to posts_path
end
end
Rails.application.routes.draw do
resources :user_areas
root to: 'home#index'
devise_for :users, controllers: {registrations: 'users/registrations'}
resources :users
resources :home
resources :emailapi
post 'emailapi/subscribe' => 'emailapi#subscribe'
resources :tags
resources :posts do
resources :comments
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment