Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
FIX issue about ghost entries
Browse files Browse the repository at this point in the history
  • Loading branch information
a-barbieri committed May 2, 2017
1 parent 6a62d32 commit b0e1388
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 20 deletions.
13 changes: 0 additions & 13 deletions app/controllers/binda/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ def create
end

def update
# Create new fields if any
# new_params[:new_assets].each do |asset|
# unless asset[:image].blank?
# new_asset = @page.assets.create( asset )
# unless new_asset
# return redirect_to edit_structure_page_path( @structure.slug, @page.slug ), flash: { error: new_asset.errors }
# end
# end
# end
if @page.update(page_params)
redirect_to structure_page_path( @structure.slug, @page.slug ), notice: 'Page was successfully updated.'
else
Expand All @@ -52,7 +43,6 @@ def destroy
redirect_to structure_pages_url( @structure.slug ), notice: 'Page was successfully destroyed.'
end


# def sort
# params[:admin_page].each_with_index do |id, i|
# Admin::Page.find( id ).update({ position: i + 1 })
Expand Down Expand Up @@ -112,9 +102,6 @@ def page_params
])
end

# def new_params
# params.require(:page).permit( new_assets:[ :id, :field_setting_id, :image, :fieldable_id ] )
# end
end
end

2 changes: 1 addition & 1 deletion app/views/binda/pages/_asset_field.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% current_asset = page.assets.where( field_setting_id: field_setting.id ).first %>
<% unless current_asset.present? %>
<% current_asset = page.assets.create()%>
<% current_asset = page.assets.create( field_setting_id: field_setting.id )%>
<% end %>
<%= f.simple_fields_for "assets_attributes[]", current_asset do |ff|%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/binda/pages/_date_field.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% current_date = page.dates.where( field_setting_id: field_setting.id ).first %>
<% unless current_date.present? %>
<% current_date = page.dates.create()%>
<% current_date = page.dates.create( field_setting_id: field_setting.id )%>
<% end %>
<%= f.simple_fields_for "dates_attributes[]", current_date do |ff|%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/binda/pages/_gallery_field.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% current_gallery = page.galleries.where( field_setting_id: field_setting.id ).first %>
<% unless current_gallery.present? %>
<% current_gallery = page.galleries.create()%>
<% current_gallery = page.galleries.create( field_setting_id: field_setting.id )%>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/binda/pages/_parent_group.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<%= render 'text_field', f: f, page: page, field_setting: field_setting %>
<% end %>
<% if field_setting.field_type == 'date' %>
<%= render 'date_field', f: f, page: page, field_setting: field_setting %>
<%# render 'date_field', f: f, page: page, field_setting: field_setting %>
<% end %>
<% if field_setting.field_type == 'repeater' %>
<%= render 'repeater_field', f: f, page: page, field_setting: field_setting %>
<%# render 'repeater_field', f: f, page: page, field_setting: field_setting %>
<% end %>
<% if field_setting.field_type == 'asset' %>
<%= render 'asset_field', f: f, page: page, field_setting: field_setting %>
<%# render 'asset_field', f: f, page: page, field_setting: field_setting %>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/binda/pages/_text_field.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% current_text = page.texts.where( field_setting_id: field_setting.id ).first %>
<% unless current_text.present? %>
<% current_text = page.texts.create()%>
<% current_text = page.texts.create( field_setting_id: field_setting.id )%>
<% end %>
<%= f.simple_fields_for "texts_attributes[]", current_text do |ff|%>
Expand Down

0 comments on commit b0e1388

Please sign in to comment.