From fc9875777276ea4aa5ae2429b774c186ab65285f Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 1 Mar 2011 15:58:42 +0800 Subject: [PATCH] base layout on id instead of name --- app/models/page.rb | 6 +++--- app/views/admin/homes/_form.html.erb | 4 ++-- app/views/admin/pages/_form.html.erb | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index b9050770..2c141841 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -15,10 +15,10 @@ class Page < Item def setup_default_value super - if self.layout_name - self.layout_id = Layout.first(:conditions => {:name => self.layout_name} ).id + if self.layout_id + self.layout_name = Layout.find(layout_id).name end end -end \ No newline at end of file +end diff --git a/app/views/admin/homes/_form.html.erb b/app/views/admin/homes/_form.html.erb index 6ab0e382..aa0395c6 100644 --- a/app/views/admin/homes/_form.html.erb +++ b/app/views/admin/homes/_form.html.erb @@ -15,8 +15,8 @@ <% end %>

-<%= f.label :layout_name, t('admin.layout_name') %> -<%= f.select :layout_name, Layout.all.map{ |l| [l.description, l.name] } %> +<%= f.label :layout_id, t('admin.layout_name') %> +<%= f.select :layout_id, Layout.all.map{ |l| [l.description, l.id] } %>

diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 05503a73..a84b872a 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -19,8 +19,8 @@ <% end %>

-<%= f.label :layout_name, t('admin.layout_name') %> -<%= f.select :layout_name, Layout.all.map{ |l| [l.description, l.name] } %> +<%= f.label :layout_id, t('admin.layout_name') %> +<%= f.select :layout_id, Layout.all.map{ |l| [l.description, l.id] } %>