FIX Neuigkeiten New

This commit is contained in:
Andreas Stephanides
2013-08-15 12:55:02 +02:00
parent 97b28fdc65
commit 5eb9e41c71
3 changed files with 4 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ class NeuigkeitenController < ApplicationController
def create def create
@neuigkeit = Neuigkeit.new(params[:neuigkeit]) @neuigkeit = Neuigkeit.new(params[:neuigkeit])
@rubrik = @neuigkeit.rubrik @rubrik = @neuigkeit.rubrik
respond_to do |format| respond_to do |format|
if @neuigkeit.save if @neuigkeit.save
format.html { redirect_to @neuigkeit, notice: 'Neuigkeit was successfully created.' } format.html { redirect_to @neuigkeit, notice: 'Neuigkeit was successfully created.' }
@@ -41,7 +42,7 @@ class NeuigkeitenController < ApplicationController
def update def update
@neuigkeit = Neuigkeit.find(params[:id]) @neuigkeit = Neuigkeit.find(params[:id])
respond_to do |format| respond_to do |format|
if @neuigkeit.update_attributes(params[:neuigkeit]) if @neuigkeit.update_attributes(params[:neuigkeit])
format.html { redirect_to @neuigkeit, notice: 'Neuigkeit was successfully updated.' } format.html { redirect_to @neuigkeit, notice: 'Neuigkeit was successfully updated.' }

View File

@@ -12,7 +12,7 @@
# #
class Neuigkeit < ActiveRecord::Base class Neuigkeit < ActiveRecord::Base
attr_accessible :datum, :text, :title, :rubrik_id attr_accessible :datum, :text, :title, :rubrik_id, :author_id
belongs_to :author, :class_name =>'User' belongs_to :author, :class_name =>'User'
belongs_to :rubrik, :class_name =>'Rubrik', :foreign_key => "rubrik_id" belongs_to :rubrik, :class_name =>'Rubrik', :foreign_key => "rubrik_id"
validates :rubrik, :presence=>true validates :rubrik, :presence=>true

View File

@@ -1,5 +1,5 @@
<h2><%= link_to neuigkeit.title,neuigkeit_path(neuigkeit) %></h2> <h2><%= link_to neuigkeit.title,neuigkeit_path(neuigkeit) %></h2>
<%= if !neuigkeit.author.nil? <%= if !neuigkeit.author.nil?
neuigkeit.author.name neuigkeit.author.email
end %> end %>
<p><%= raw(neuigkeit.text) %></p> <p><%= raw(neuigkeit.text) %></p>