Beispiele hinzugefügt
This commit is contained in:
3
app/assets/javascripts/beispiele.js.coffee
Normal file
3
app/assets/javascripts/beispiele.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/stylesheets/beispiele.css.scss
Normal file
3
app/assets/stylesheets/beispiele.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the beispiele controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
83
app/controllers/beispiele_controller.rb
Normal file
83
app/controllers/beispiele_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
class BeispieleController < ApplicationController
|
||||
# GET /beispiele
|
||||
# GET /beispiele.json
|
||||
def index
|
||||
@beispiele = Beispiel.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @beispiele }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /beispiele/1
|
||||
# GET /beispiele/1.json
|
||||
def show
|
||||
@beispiel = Beispiel.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @beispiel }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /beispiele/new
|
||||
# GET /beispiele/new.json
|
||||
def new
|
||||
@beispiel = Beispiel.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @beispiel }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /beispiele/1/edit
|
||||
def edit
|
||||
@beispiel = Beispiel.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /beispiele
|
||||
# POST /beispiele.json
|
||||
def create
|
||||
@beispiel = Beispiel.new(params[:beispiel])
|
||||
|
||||
respond_to do |format|
|
||||
if @beispiel.save
|
||||
format.html { redirect_to @beispiel, notice: 'Beispiel was successfully created.' }
|
||||
format.json { render json: @beispiel, status: :created, location: @beispiel }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @beispiel.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /beispiele/1
|
||||
# PUT /beispiele/1.json
|
||||
def update
|
||||
@beispiel = Beispiel.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @beispiel.update_attributes(params[:beispiel])
|
||||
format.html { redirect_to @beispiel, notice: 'Beispiel was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @beispiel.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /beispiele/1
|
||||
# DELETE /beispiele/1.json
|
||||
def destroy
|
||||
@beispiel = Beispiel.find(params[:id])
|
||||
@beispiel.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to beispiele_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
2
app/helpers/beispiele_helper.rb
Normal file
2
app/helpers/beispiele_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module BeispieleHelper
|
||||
end
|
||||
7
app/models/beispiel.rb
Normal file
7
app/models/beispiel.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Beispiel < ActiveRecord::Base
|
||||
has_paper_trail
|
||||
attr_accessible :desc, :name, :file, :lva_id
|
||||
has_attached_file :file
|
||||
belongs_to :lva
|
||||
translates :desc, :fallbacks_for_empty_translations => true
|
||||
end
|
||||
@@ -4,4 +4,5 @@ class Lva < ActiveRecord::Base
|
||||
has_and_belongs_to_many :modul
|
||||
has_and_belongs_to_many :semester
|
||||
translates :desc, :fallbacks_for_empty_translations => true
|
||||
has_many :beispiele , :class_name => "Beispiel"
|
||||
end
|
||||
|
||||
@@ -9,7 +9,5 @@ def moderator
|
||||
end
|
||||
end
|
||||
|
||||
def moderator=(id)
|
||||
User.find(id).add_role(:newsmoderator, self)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
12
app/views/beispiele/_form.html.erb
Normal file
12
app/views/beispiele/_form.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<%= semantic_form_for @beispiel, :html => { :multipart => true } do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :name %>
|
||||
<%= f.input :desc %>
|
||||
<%= f.input :file , :as=>:file %>
|
||||
<%= f.input :lva, :as=>:radio, :collection => Lva.all%>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
6
app/views/beispiele/edit.html.erb
Normal file
6
app/views/beispiele/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing beispiel</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @beispiel %> |
|
||||
<%= link_to 'Back', beispiele_path %>
|
||||
25
app/views/beispiele/index.html.erb
Normal file
25
app/views/beispiele/index.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<h1>Listing beispiele</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Desc</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @beispiele.each do |beispiel| %>
|
||||
<tr>
|
||||
<td><%= beispiel.name %></td>
|
||||
<td><%= beispiel.desc %></td>
|
||||
<td><%= link_to 'Show', beispiel %></td>
|
||||
<td><%= link_to 'Edit', edit_beispiel_path(beispiel) %></td>
|
||||
<td><%= link_to 'Destroy', beispiel, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Beispiel', new_beispiel_path %>
|
||||
5
app/views/beispiele/new.html.erb
Normal file
5
app/views/beispiele/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New beispiel</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', beispiele_path %>
|
||||
16
app/views/beispiele/show.html.erb
Normal file
16
app/views/beispiele/show.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= @beispiel.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Desc:</b>
|
||||
<%= @beispiel.desc %>
|
||||
<%= @beispiel.file.url %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_beispiel_path(@beispiel) %> |
|
||||
<%= link_to 'Back', beispiele_path %>
|
||||
@@ -16,5 +16,7 @@
|
||||
<p>
|
||||
<%= @lva.desc %>
|
||||
</p>
|
||||
<% @lva.beispiele.each do |beispiel| %>
|
||||
<%= link_to beispiel.name, beispiel.file.url %>
|
||||
|
||||
|
||||
<% end%>
|
||||
|
||||
Reference in New Issue
Block a user