This commit is contained in:
Andreas Stephanides
2013-08-23 14:30:31 +02:00
7 changed files with 62 additions and 34 deletions

View File

@@ -11,9 +11,10 @@
class Themengruppe < ActiveRecord::Base class Themengruppe < ActiveRecord::Base
WORD_COUNT = 50 WORD_COUNT = 50
attr_accessible :text, :title attr_accessible :text, :title, :picture
has_many :themen, class_name: 'Thema' has_many :themen, class_name: 'Thema'
has_many :fragen, through: :themen has_many :fragen, through: :themen
mount_uploader :picture, PictureUploader
validates :title, :presence => true validates :title, :presence => true

View File

@@ -2,6 +2,7 @@
<%= semantic_form_for @thema do |f| %> <%= semantic_form_for @thema do |f| %>
<%= f.inputs do %> <%= f.inputs do %>
<%= f.input :title %> <%= f.input :title %>
<%= f.input :picture, :as => :file %>
<%= f.input :themengruppe %> <%= f.input :themengruppe %>
<%= f.input :text, :as=>:tinymce_text%> <%= f.input :text, :as=>:tinymce_text%>
<% end %> <% end %>

View File

@@ -1,7 +1,9 @@
<%= semantic_form_for @themengruppe do |f| %> <%= semantic_form_for @themengruppe do |f| %>
<%= f.inputs do %> <%= f.inputs do %>
<%= f.input :title %> <%= f.input :title %>
<%= f.input :picture, :as => :file %>
<%= f.input :text %> <%= f.input :text %>
<% end %> <% end %>
<%= f.actions do %> <%= f.actions do %>

View File

@@ -1,5 +1,14 @@
<div class="row-fluid">
<div class="span2">
<%= image_tag themengruppe.picture.thumb.url,{:class=>"img-circle"} %>
</div>
<div class="span10">
<h3><%= link_to themengruppe.title, themengruppe %> </h3> <h3><%= link_to themengruppe.title, themengruppe %> </h3>
</div>
</div>
<br/>
<div class="row-fluid">
<div class="span12">
<p> <p>
<%= if themengruppe.text.split.size > Themengruppe::WORD_COUNT <%= if themengruppe.text.split.size > Themengruppe::WORD_COUNT
themengruppe.text.split[0..Themengruppe::WORD_COUNT].join(" ") + " ..." themengruppe.text.split[0..Themengruppe::WORD_COUNT].join(" ") + " ..."
@@ -7,7 +16,11 @@
themengruppe.text themengruppe.text
end%> end%>
</p> </p>
<br/> </div>
</div>
<div class="row-fluid">
<div class="span12">
<b><%= I18n.t("themengruppe.themen") %></b> <b><%= I18n.t("themengruppe.themen") %></b>
<ul> <ul>
<% themengruppe.themen.each do |t| %> <% themengruppe.themen.each do |t| %>
@@ -16,3 +29,6 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
</div>
</div>

View File

@@ -1,20 +1,22 @@
<div class="container-fluid"> <div class="container-fluid">
<% @themengruppen.each_slice(2) do |row| %> <% @themengruppen.each_slice(2) do |row| %>
<div class="row-fluid"> <div class="row-fluid">
<% row.each do |themengruppe| %> <% row.each do |themengruppe| %>
<div class="span6 equalheight"> <div class="span6 equalheight">
<div class="themengruppe"> <div class="container-fluid">
<%= render themengruppe %> <%= render themengruppe %>
<p> <br/>
<div class="row-fluid">
<%= link_to 'Edit', edit_themengruppe_path(themengruppe) %> <%= link_to 'Edit', edit_themengruppe_path(themengruppe) %>
</p>
</div> </div>
</div> </div>
<br/>
</div>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
</div> </div>
<br/> <br/>
<script class="hidden-phone"> <script class="hidden-phone">

View File

@@ -66,6 +66,7 @@
resources :beispiele resources :beispiele
resources :attachment
resources :themen resources :themen
resources :themengruppen do resources :themengruppen do
resources :themen, :only=>[:new, :show] resources :themen, :only=>[:new, :show]

View File

@@ -0,0 +1,5 @@
class AddPictureToThemengruppe < ActiveRecord::Migration
def change
add_column :themengruppen, :picture, :string
end
end