Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionView::Template::Error (Symbol or String expected, but NilClass given.) #219

Open
ldco2016 opened this issue Nov 21, 2017 · 0 comments

Comments

@ldco2016
Copy link

ldco2016 commented Nov 21, 2017

Today I started to get this error after I uploaded my latest blog:

ActionView::Template::Error (Symbol or String expected, but NilClass given.)

I noticed I only got the error when I was signed in as admin.

I looked at my heroku logs which referenced code that was tied to my admin_actions partial:

<div class="blog-post">
    <h2 class="blog-post-title"><%= link_to blog.title.upcase, blog %></h2>
    <p class="blog-post-meta">Published <%= distance_of_time_in_words(blog.created_at, Time.now) %> ago</a></p>

    <!-- <%= render partial: 'blogs/admin_actions', locals: {blog: blog} %>

    <p><%= markdown blog.body %></p> -->

 </div><!-- /.blog-post -->

but the logs also references:

2017-11-21T22:43:24.204407+00:00 app[web.1]: F, [2017-11-21T22:43:24.204360 #4] FATAL -- : [58b9a24b-3a61-4e43-8e61-c92eb08c5258] app/helpers/blogs_helper.rb:8:in block_code'`

which is: CodeRay.scan(code, language).div

inside the block_code method inside of CodeRayify class:

module BlogsHelper
	def gravatar_helper user
		image_tag "https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user.email)}", width: 60
	end

	class CodeRayify < Redcarpet::Render::HTML
		def block_code(code, language)
			CodeRay.scan(code, language).div
		end
	end

	def markdown(text)
		coderayify = CodeRayify.new(filter_html: true, hard_wrap: true)

		options = {
			fenced_code_blocks: true,
			no_intra_emphasis: true,
			autolink: true,
			lax_html_blocks: true,
		}

		markdown_to_html = Redcarpet::Markdown.new(coderayify, options)
		markdown_to_html.render(text).html_safe
	end

	def blog_status_color blog
		'color: red;' if blog.draft?
	end
end

I was wondering if this was a known error or if someone can assist me to identify if CodeRay.scan(code, language).div is no longer a valid way to write this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant