parent
5de8e1c2f2
commit
16f70437d1
@ -0,0 +1,2 @@
|
|||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,4 @@
|
|||||||
|
/*
|
||||||
|
Place all the styles related to the matching controller here.
|
||||||
|
They will automatically be included in application.css.
|
||||||
|
*/
|
@ -0,0 +1,83 @@
|
|||||||
|
class ForumsController < ApplicationController
|
||||||
|
# GET /forums
|
||||||
|
# GET /forums.json
|
||||||
|
def index
|
||||||
|
@forums = Forum.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @forums }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /forums/1
|
||||||
|
# GET /forums/1.json
|
||||||
|
def show
|
||||||
|
@forum = Forum.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @forum }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /forums/new
|
||||||
|
# GET /forums/new.json
|
||||||
|
def new
|
||||||
|
@forum = Forum.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @forum }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /forums/1/edit
|
||||||
|
def edit
|
||||||
|
@forum = Forum.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /forums
|
||||||
|
# POST /forums.json
|
||||||
|
def create
|
||||||
|
@forum = Forum.new(params[:forum])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @forum.save
|
||||||
|
format.html { redirect_to @forum, notice: 'Forum was successfully created.' }
|
||||||
|
format.json { render json: @forum, status: :created, location: @forum }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /forums/1
|
||||||
|
# PUT /forums/1.json
|
||||||
|
def update
|
||||||
|
@forum = Forum.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @forum.update_attributes(params[:forum])
|
||||||
|
format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /forums/1
|
||||||
|
# DELETE /forums/1.json
|
||||||
|
def destroy
|
||||||
|
@forum = Forum.find(params[:id])
|
||||||
|
@forum.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to forums_url }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,2 @@
|
|||||||
|
module ForumsHelper
|
||||||
|
end
|
@ -0,0 +1,3 @@
|
|||||||
|
class Forum < ActiveRecord::Base
|
||||||
|
# attr_accessible :title, :body
|
||||||
|
end
|
@ -0,0 +1,17 @@
|
|||||||
|
<%= form_for(@forum) do |f| %>
|
||||||
|
<% if @forum.errors.any? %>
|
||||||
|
<div id="error_explanation">
|
||||||
|
<h2><%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<% @forum.errors.full_messages.each do |msg| %>
|
||||||
|
<li><%= msg %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<%= f.submit %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
@ -0,0 +1,6 @@
|
|||||||
|
<h1>Editing forum</h1>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
|
||||||
|
<%= link_to 'Show', @forum %> |
|
||||||
|
<%= link_to 'Back', forums_path %>
|
@ -0,0 +1,21 @@
|
|||||||
|
<h1>Listing forums</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% @forums.each do |forum| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= link_to 'Show', forum %></td>
|
||||||
|
<td><%= link_to 'Edit', edit_forum_path(forum) %></td>
|
||||||
|
<td><%= link_to 'Destroy', forum, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<%= link_to 'New Forum', new_forum_path %>
|
@ -0,0 +1,5 @@
|
|||||||
|
<h1>New forum</h1>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
|
||||||
|
<%= link_to 'Back', forums_path %>
|
@ -0,0 +1,5 @@
|
|||||||
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
|
|
||||||
|
<%= link_to 'Edit', edit_forum_path(@forum) %> |
|
||||||
|
<%= link_to 'Back', forums_path %>
|
@ -0,0 +1,8 @@
|
|||||||
|
class CreateForums < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :forums do |t|
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue