Fix fetch wrong version page_context problem.
This commit is contained in:
parent
74d1986002
commit
bedcf2b985
|
@ -9,7 +9,7 @@ class PageContentsController < OrbitAdminController
|
|||
else
|
||||
page = Page.where(:page_id => params[:page_id]).first
|
||||
name = page.name rescue ""
|
||||
html = page.page_contexts.last.content rescue ""
|
||||
html = page.page_contexts.order(:version=>-1).first.content rescue ""
|
||||
url_to_edit = OrbitHelper.user_can_edit?(page) ? "/admin/page_contents/new?page_id=#{page.id.to_s}" : ""
|
||||
end
|
||||
request = OrbitHelper.request
|
||||
|
|
|
@ -13,7 +13,10 @@ class PageContext
|
|||
# field :current, :type => Boolean, :default => false
|
||||
|
||||
belongs_to :page
|
||||
|
||||
before_create do |record|
|
||||
last_version = record.page.page_contexts.order(:version=>-1).first.version rescue 0
|
||||
record.version = last_version + 1
|
||||
end
|
||||
def pp_object
|
||||
page.title
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<% end %>
|
||||
<% @page_context = @page.page_contexts.order(:version=>-1).first #take last version page_context %>
|
||||
<%= form_for @page_content, :url => {:action => :create}, :html => {:class => 'form-horizontal main-forms'} do |f| %>
|
||||
<fieldset>
|
||||
<div class="input-area">
|
||||
|
@ -31,7 +32,7 @@
|
|||
<%= label_tag(locale, t(:content), :class=>"control-label muted") %>
|
||||
<div class="controls">
|
||||
<div class="textarea">
|
||||
<%= con.text_area locale, :class => "ckeditor input-block-level", :value => (@page.page_contexts.last.content_translations[locale] rescue nil)%>
|
||||
<%= con.text_area locale, :class => "ckeditor input-block-level", :value => (@page_context.content_translations[locale] rescue nil)%>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -42,7 +43,6 @@
|
|||
</div>
|
||||
<div class="form-actions">
|
||||
<%= f.hidden_field :page_id, :value=>@page.id.to_s %>
|
||||
<%= f.hidden_field :version, :value=>((@page.page_contexts.last.version + 1) rescue 1)%>
|
||||
<input type="hidden" name="referer_url" value="<%= request.referer %>">
|
||||
<%= f.submit t("page_content.save"), :class=> "btn btn-primary bt-form-save" %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue