Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/controllers/blogs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ def index
@search_end_at = params[:search_end_at]

if @search_text.present?
@blogs = @blogs.where("title LIKE \"%#{@search_text}%\" OR body LIKE \"%#{@search_text}%\"")
@blogs = @blogs.where("title LIKE :search_text OR body LIKE :search_text", search_text: "%#{@search_text}%")
end

if @search_start_at.present?
@blogs = @blogs.where("created_at >= '#{@search_start_at}'")
@blogs = @blogs.where("created_at >= ?", @search_start_at)
end

if @search_end_at.present?
@blogs = @blogs.where("created_at <= '#{@search_end_at}'")
@blogs = @blogs.where("created_at <= ?", @search_end_at)
end
end

def show
@blog = Blog.find(params[:id])
@blog = Blog.published.find(params[:id])
end
end