diff --git a/app/controllers/admin/page_contents_controller.rb b/app/controllers/admin/page_contents_controller.rb index 8465347..800f963 100644 --- a/app/controllers/admin/page_contents_controller.rb +++ b/app/controllers/admin/page_contents_controller.rb @@ -18,10 +18,10 @@ class Admin::PageContentsController < OrbitAdminController end def create - @page_content = PageContext.new(update_params) + @page_content = PageContext.new(update_params) @page_content.update_user_id = current_user.id - @page_content.save - redirect_to admin_page_contents_path + @page_content.save + redirect_to params['referer_url'] end def view diff --git a/app/controllers/page_contents_controller.rb b/app/controllers/page_contents_controller.rb index 1c35de9..434a9f7 100644 --- a/app/controllers/page_contents_controller.rb +++ b/app/controllers/page_contents_controller.rb @@ -1,9 +1,11 @@ class PageContentsController < OrbitAdminController - def index - params = OrbitHelper.params - page = Page.where(:page_id => params[:page_id]).first - { - "html" => (page.page_contexts.last.content rescue "") - } - end + def index + params = OrbitHelper.params + page = Page.where(:page_id => params[:page_id]).first + url_to_edit = OrbitHelper.user_can_edit?(page) ? "/admin/page_contents/new?page_id=#{page.id.to_s}" : "" + { + "html" => (page.page_contexts.last.content rescue ""), + "url_to_edit" => url_to_edit + } + end end \ No newline at end of file diff --git a/app/views/admin/page_contents/new.html.erb b/app/views/admin/page_contents/new.html.erb index 35fcced..3c58621 100644 --- a/app/views/admin/page_contents/new.html.erb +++ b/app/views/admin/page_contents/new.html.erb @@ -33,6 +33,7 @@