section image select and basic image show
This commit is contained in:
@ -7,7 +7,7 @@ module Merged
|
||||
@image_data = @images.collect{|i|
|
||||
data = i.attributes.dup
|
||||
data[:url] = view_context.asset_path(i.asset_name)
|
||||
data[:link] = view_context.image_url(i.id)
|
||||
data[:link] = build_link_for(i)
|
||||
data[:created_at] = i.created_at.to_date
|
||||
data[:created] = i.created_at.to_i
|
||||
data[:aspect_ratio] = i.aspect_ratio.join("/")
|
||||
@ -16,6 +16,10 @@ module Merged
|
||||
}
|
||||
end
|
||||
|
||||
def show
|
||||
@image = Image.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
new_image = Image.create_new(params['filename'] , params['image_file'])
|
||||
redirect = :images
|
||||
@ -26,6 +30,13 @@ module Merged
|
||||
redirect_to redirect
|
||||
end
|
||||
|
||||
private
|
||||
def build_link_for(image)
|
||||
if(params[:section_id])
|
||||
return view_context.section_set_image_url(params[:section_id] , image_id: image.id)
|
||||
end
|
||||
view_context.image_url(image.id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -7,10 +7,6 @@ module Merged
|
||||
@page = Page.find(params[:page_id])
|
||||
end
|
||||
|
||||
def select_image
|
||||
@images = Image.all
|
||||
end
|
||||
|
||||
def select_template
|
||||
@sections = SectionStyle.all
|
||||
end
|
||||
@ -37,9 +33,9 @@ module Merged
|
||||
end
|
||||
|
||||
def set_image
|
||||
@section.image = params[:image]
|
||||
@section.image_id = params[:image_id]
|
||||
@section.save
|
||||
redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image}"
|
||||
redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image.name}"
|
||||
end
|
||||
|
||||
def set_template
|
||||
|
Reference in New Issue
Block a user