(Dev environment) ActionView::Template::Error (broken theme)

In a theme, I was trying to inject a button using a plugin outlet,

I accidentally left out a > like so:

<button id="myb" class="mybutton toggler btn-flat"
//------------------------------------------------^ Right here
  <i class="fa fa-expand d-icon d-icon-expand"></i>

I guess that since this was in a handlebars template, it validated ok and the theme saved without throwing an error in the editor. Ever since then all pages give the same error:

ActionView::Template::Error at /
Pre compilation failed for: 
    <button id="myb" class="mybutton toggler btn-flat"<i class="fa fa-expand d-icon d-icon-expand"></i></button>

. Compiler said: Error: Syntax error at line 2 col 54: < is not a valid character within attribute names

Or this:

I tried safe-mode and I guess that does not exist in dev environment

I have a backup from yesterday that I can restore no problem, but I wanted to check if there’s any way to address this without restoring a backup, like maybe manually edit the theme files?

All of this is in a Dev environment.

1 Like

If you already logged-in and visit the /admin URL directly then it won’t throw you that error. Can’t you access the admin itself?

1 Like

I am pretty sure that would have worked if I was indeed logged in, but I am not.

So, I tried to go to the admin login at /u/admin-login and that works. It asks for the admin email and sends a login link.


I then check mailcatcher and that also works

As you can see the generated link is http://localhost/u/...

While I usually use http://localhost:3000/

Clicking on the login link gives me this:

Manually adding :3000 like this:


to the link makes two things happen,

1- The link then gives a 302 to http://localhost:3000/ like so:

2- then http://localhost:3000/ gives a 500 like so:

And I see this again:

I think it might be best to go ahead and restore from a backup unless you see any simple easy-to-fix problems with what I posted above.

Can you disable the theme from the rails consuls?

1 Like

I’ve been trying to look for a way to do that as well without luck.

1 Like

Safe-mode works for me in my dev environment. What do you see when you try to access it?


I see the same page with the error from above.

And since you’ve confirmed that safe-mode works fine in dev on your end, I’m guessing I also have another problem somewhere else maybe :sweat_smile:

I’m sure something can be done with the rails console. Do you know the ID or the name of the problematic theme? And is it a child theme of your default theme?


Yes, the theme ID is 81 and no, it’s not a child of the default theme.

1 Like

Alright, do you know where the broken code is? Is it in Common > </head>?

1 Like

Yes, it’s in common > head_tag

Ok, how many records does this return? It should return one record and the record’s value should have the broken code.

ThemeField.where(theme_id: 81, target_id: 0, name: "head_tag")

Indeed @Osama it did exactly as you said :ok_hand: and here’s what I see:

ThemeField Load (1.3ms)  SELECT "theme_fields".* FROM "theme_fields" WHERE "theme_fields"."theme_id" = 81 AND "theme_fields"."target_id" = 0 AND "theme_fields"."name" = 'head_tag'
=> [#<ThemeField:0x00007f18ab6f5728
  id: 144,
  theme_id: 81,
  target_id: 0,
  name: "head_tag",
   "\n" +
   "<script type='text/x-handlebars' data-template-name='/connectors/after-d-editor/aaa'>\n" +
   "    <button id=\"myb\" class=\"mybutton toggler btn-flat\"<i class=\"fa fa-expand d-icon d-icon-expand\"></i></button>\n" +
   "</script>\n" +
   "\n" +
   "<script>\n" +
   "$( document ).ready(function() {\n" +
   "    $('#myb').click(function(){\n" +
   "            if (!$('body').hasClass(\"distractionf\")) {\n" +
   "                $('body').addClass(\"distractionf\");\n" +
   "            } else {\n" +
   "                $('body').removeClass(\"distractionf\");\n" +
   "            }\n" +
   "    }); \n" +
   "});\n" +
   "</script>\n" +
  value_baked: nil,
  created_at: Sat, 07 Apr 2018 10:01:08 UTC +00:00,
  updated_at: Sat, 07 Apr 2018 12:28:26 UTC +00:00,
  compiler_version: 5,
  error: nil,
  upload_id: nil,
1 Like

Great! Now run this to remove the broken code:

field = ThemeField.where(theme_id: 81, target_id: 0, name: "head_tag").first
field.value = ""

And everything should get back to normal :rainbow:


Hooray!! :confetti_ball: That worked flawlessly!

This is fantastic. Thank you so much for all the help :heart::sunflower: