Einbindung Beispieluploader
This commit is contained in:
@@ -25,7 +25,7 @@ class BeispieleController < ApplicationController
|
||||
# GET /beispiele/new.json
|
||||
def new
|
||||
@beispiel = Beispiel.new
|
||||
|
||||
@beispiel.lva_id = params[:lva_id]
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @beispiel }
|
||||
|
||||
@@ -11,14 +11,15 @@ class LvasController < ApplicationController
|
||||
def show
|
||||
@lva = Lva.find_by_id(params[:id])
|
||||
@toolbar_elements<<{:icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_lva_path(@lva)}
|
||||
@toolbar_elements<<{:icon=>:plus, :text => "Neues Beispiel", :path=> new_beispiel_path(:lva_id =>@lva.id)}
|
||||
end
|
||||
|
||||
# GET /lvas/new
|
||||
# GET /lvas/new.json
|
||||
def new
|
||||
@lva = Lva.new
|
||||
modul=Modul.find(params[:modul_id])
|
||||
@lva.modul<<modul #
|
||||
modul=Modul.find_by_id(params[:modul_id])
|
||||
@lva.modul<<modul unless modul.nil?
|
||||
|
||||
end
|
||||
|
||||
@@ -31,7 +32,7 @@ class LvasController < ApplicationController
|
||||
# POST /lvas.json
|
||||
def create
|
||||
@lva = Lva.new(params[:lva])
|
||||
Lva.add_semesters(@lva)
|
||||
@lva.add_semesters
|
||||
respond_to do |format|
|
||||
if @lva.save
|
||||
|
||||
|
||||
@@ -19,4 +19,9 @@ class Beispiel < ActiveRecord::Base
|
||||
attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache
|
||||
belongs_to :lva
|
||||
mount_uploader :beispieldatei, BeispieldateiUploader
|
||||
validates :beispieldatei, :presence => true
|
||||
validates :name, :presence => true
|
||||
validates :lva_id, :presence => true
|
||||
validates :lva, :presence => true
|
||||
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= f.input :desc %>
|
||||
<%= f.file_field :beispieldatei %>
|
||||
<%= f.hidden_field :beispieldatei_cache %>
|
||||
<%= f.input :lva, :as=>:radio, :collection => Lva.all%>
|
||||
<%= f.input :lva, :as=>:select, :collection => Lva.all%>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
|
||||
Reference in New Issue
Block a user