* Inflections für Thema/Themen etc.
  * Korrigierte Views
This commit is contained in:
HausdorffHimself
2013-08-06 02:06:48 +02:00
parent b560940a70
commit 3be95d2ede
16 changed files with 167 additions and 21 deletions

View File

@@ -1,10 +1,9 @@
class Frage < ActiveRecord::Base class Frage < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title attr_accessible :text, :title
belongs_to :thema belongs_to :thema
validates :thema, :presence => true validates :thema, :presence => true
validates :title, :prescece => true validates :title, :presence => true
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
end end

View File

@@ -1,3 +1,10 @@
class Frage < ActiveRecord::Base class Frage < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title attr_accessible :text, :title
belongs_to :thema
validates :thema, :presence => true
validates :title, :presence => true
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
end end

View File

@@ -1,10 +1,11 @@
class Thema < ActiveRecord::Base class Thema < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title attr_accessible :text, :title
has_many :fragen has_many :fragen
has_many :attachments has_many :attachments
belongs_to :themengruppe belongs_to :themengruppe, :foreign_key => "themengruppe_id"
validates :themengruppe, :presence => true validates :themengruppe, :presence => true
validates :title, :presence => true validates :title, :presence => true
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
end end

View File

@@ -1,5 +1,11 @@
class Thema < ActiveRecord::Base class Thema < ActiveRecord::Base
attr_accessible :text, :title attr_accessible :text, :title
has_many :fragen has_many :fragen
has_many :attachments
belongs_to :themengruppe belongs_to :themengruppe
validates :themengruppe, :presence => true
validates :title, :presence => true
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
end end

View File

@@ -1,8 +1,9 @@
class Themengruppe < ActiveRecord::Base class Themengruppe < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title attr_accessible :text, :title
has_many :themen has_many :themen
has_many :fragen, through: :themen has_many :fragen, through: :themen
validates :title, :presence => true validates :title, :presence => true
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
end end

View File

@@ -1,3 +1,8 @@
class Themengruppe < ActiveRecord::Base class Themengruppe < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title attr_accessible :text, :title
has_many :themen
has_many :fragen, through: :themen
validates :title, :presence => true
end end

View File

@@ -1,12 +1,10 @@
<p id="notice"><%= notice %></p> <p id="notice"><%= notice %></p>
<p> <h1>
<b>Title:</b>
<%= @frage.title %> <%= @frage.title %>
</p> </h1>
<p> <p>
<b>Text:</b>
<%= @frage.text %> <%= @frage.text %>
</p> </p>

View File

@@ -0,0 +1,15 @@
<p id="notice"><%= notice %></p>
<p>
<b>Title:</b>
<%= @frage.title %>
</p>
<p>
<b>Text:</b>
<%= @frage.text %>
</p>
<%= link_to 'Edit', edit_frage_path(@frage) %> |
<%= link_to 'Back', fragen_path %>

View File

@@ -9,17 +9,17 @@
<th></th> <th></th>
</tr> </tr>
<% @themengruppen.each do |themagruppen| %> <% @themengruppen.each do |themengruppe| %>
<tr> <tr>
<td><%= themagruppen.title %></td> <td><%= themengruppe.title %></td>
<td><%= themagruppen.text %></td> <td><%= themengruppe.text %></td>
<td><%= link_to 'Show', themagruppen %></td> <td><%= link_to 'Show', themengruppe %></td>
<td><%= link_to 'Edit', edit_themagruppen_path(themagruppen) %></td> <td><%= link_to 'Edit', edit_themengruppe_path(themengruppe) %></td>
<td><%= link_to 'Destroy', themagruppen, method: :delete, data: { confirm: 'Are you sure?' } %></td> <td><%= link_to 'Destroy', themengruppe, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr> </tr>
<% end %> <% end %>
</table> </table>
<br /> <br />
<%= link_to 'New Themengruppe', new_themagruppen_path %> <%= link_to 'New Themengruppe', new_themengruppe_path %>

View File

@@ -0,0 +1,25 @@
<h1>Listing themengruppen</h1>
<table>
<tr>
<th>Title</th>
<th>Text</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @themengruppen.each do |themagruppen| %>
<tr>
<td><%= themagruppen.title %></td>
<td><%= themagruppen.text %></td>
<td><%= link_to 'Show', themagruppen %></td>
<td><%= link_to 'Edit', edit_themagruppen_path(themagruppen) %></td>
<td><%= link_to 'Destroy', themagruppen, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Themengruppe', new_themagruppen_path %>

View File

@@ -27,8 +27,8 @@ inflect.plural 'beispiel', 'beispiele'
inflect.singular 'beispiele', 'beispiel' inflect.singular 'beispiele', 'beispiel'
inflect.plural 'themengruppe', 'themengruppen' inflect.plural 'themengruppe', 'themengruppen'
inflect.singular 'themengruppen', 'themengruppe' inflect.singular 'themengruppen', 'themengruppe'
inflect.plural 'thema', 'themen' inflect.plural /thema$/, 'themen'
inflect.singular 'themen', 'thema' inflect.singular /themen$/, 'thema'
inflect.plural 'frage', 'fragen' inflect.plural 'frage', 'fragen'
inflect.singular 'fragen', 'frage' inflect.singular 'fragen', 'frage'
end end

View File

@@ -27,9 +27,8 @@ inflect.plural 'beispiel', 'beispiele'
inflect.singular 'beispiele', 'beispiel' inflect.singular 'beispiele', 'beispiel'
inflect.plural 'themengruppe', 'themengruppen' inflect.plural 'themengruppe', 'themengruppen'
inflect.singular 'themengruppen', 'themengruppe' inflect.singular 'themengruppen', 'themengruppe'
inflect.plural 'thema', 'themen' inflect.plural /thema$/, 'themen'
inflect.singular 'themen', 'thema' inflect.singular /^themen$/, 'thema'
inflect.plural 'frage', 'fragen' inflect.plural 'frage', 'fragen'
inflect.singular 'fragen', 'frage' inflect.singular 'fragen', 'frage'
end end

View File

@@ -0,0 +1,7 @@
class AddIdToThemen < ActiveRecord::Migration
def change
add_column :themen, :themengruppe_id, :integer
add_column :attachments, :thema_id, :integer
add_column :fragen, :thema_id, :integer
end
end

View File

@@ -0,0 +1,7 @@
class AddIdToThemen < ActiveRecord::Migration
def change
add_column :themen, :themengruppe_id, :integer
add_column :attachments, :thema_id, :integer
add_column :fragen, :thema_id, :integer
end
end

View File

@@ -0,0 +1,38 @@
class TranslateThemen < ActiveRecord::Migration
def up
Thema.create_translation_table!({
:title => :string,
:text => :text
}, {
#:migrate_data => true
})
add_column :thema_translations, :themen_id, :integer
remove_column :thema_translations, :thema_id
Themengruppe.create_translation_table!({
:title => :string,
:text => :text
}, {
#:migrate_data => true
})
add_column :themengruppe_translations, :themengruppen_id, :integer
remove_column :themengruppe_translations, :themengruppe_id
Frage.create_translation_table!({
:title => :string,
:text => :text
}, {
#:migrate_data => true
})
add_column :frage_translations, :fragen_id, :integer
remove_column :frage_translations, :frage_id
end
def down
Thema.drop_translation_table! #:migrate_data => true
Themengruppe.drop_translation_table! #:migrate_data => true
Frage.drop_translation_table! #:migrate_data => true
end
end

View File

@@ -0,0 +1,38 @@
class TranslateThemen < ActiveRecord::Migration
def up
Thema.create_translation_table!({
:title => :string,
:text => :text
}, {
#:migrate_data => true
})
add_column :thema_translations, :themen_id, :integer
remove_column :themagruppe_translations, :thema_id
Themengruppe.create_translation_table!({
:title => :string,
:text => :text
}, {
#:migrate_data => true
})
add_column :themengruppe_translations, :themengruppen_id, :integer
remove_column :themengruppe_translations, :themengruppe_id
Frage.create_translation_table!({
:title => :string,
:text => :text
}, {
#:migrate_data => true
})
add_column :frage_translations, :fragen_id, :integer
remove_column :frage_translations, :frage_id
end
def down
Thema.drop_translation_table! #:migrate_data => true
Themengruppe.drop_translation_table! #:migrate_data => true
Frage.drop_translation_table! #:migrate_data => true
end
end