Unexpected = in haml file after updating Ruby - ruby-on-rails

I am running a rails application (rails: 4.2 and ruby 2.2.3). I am trying to update my ruby to 2.4.4 and have been able to successfully run bundle install. However, when I start the server and go to the home page of my application, I encounter a unexpected = in the application.html.haml file for this line:
= favicon_link_tag 'favicon.ico'
Has anyone here encountered an error like this?
P.S. if this question has been posted before can someone redirect me to it as I cannot find this problem.
%head
%base{:href => "/dashboard"}
%title Title Page
= favicon_link_tag 'favicon.ico'
= stylesheet_link_tag "application", :media => nil
= javascript_include_tag "application"
= csrf_meta_tags
%body{'ng-app'=>'thumper','ng-controller'=>'MainController'}
- if signed_in?
.navbar.navbar-inverse.navbar-fixed-top{:style => 'padding-top:0px;height: 30px;'}
.container
%button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse"}
%a.navbar-brand{:href => "/", :target => "_self"}
= image_tag "main_image.png", :style => 'width:65px;', :alt => 'company_name'
.navbar-collapse.collapse
%ul.nav.navbar-nav
%li
%a{:href => "/faq", :target => "_self"}
%i.fa.fa-lightbulb-o
FAQ
%li
This is my initial part of my application.html.haml file. I get the following error:
DEPRECATED: Please use restforce (https://github.com/ejholmes/restforce) instead.
=> Booting Thin
=> Rails 4.2.11 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop
Started GET "/testpage" for 127.0.0.1 at 2019-03-12 09:32:47 -0500
ActiveRecord::SchemaMigration Load (44.9ms) SELECT `schema_migrations`.* FROM `schema_migrations`
Processing by TestController#foo as HTML
HERE
Rendered test/foo.html within layouts/application (2.9ms)
Completed 500 Internal Server Error in 1964ms (ActiveRecord: 0.0ms)
ExecJS::RuntimeError - SyntaxError: [stdin]:959:20: unexpected =:
app/views/layouts/application.html.haml:7:in `_app_views_layouts_application_html_haml___861496224579637971_70314333220700'
app/lib/cors.rb:12:in `call'
app/lib/cors.rb:12:in `call'
Started POST "/__better_errors/1f18681361fed4ae/variables" for 127.0.0.1 at 2019-03-12 09:32:50 -0500
The web browser looks like this:

Related

redmine upgrade to 3.4.4 not working [ActionView::Template::Error (undefined method `default_users_time_zone')]

Every thing worked fine for me with Redmine 3.3. Now I wanted to upgrade to 3.4.4 and Redmine is no longer running. I searched the internet but did not find the exact same problem. Similar problems where caused by plugins but I do not have any plugins installed. I use the Passenger Docker image of Redmine.
The logs give me the following error message:
Processing by WelcomeController#index as HTML
Current user: anonymous
Redirected to http://0.0.0.0/login?back_url=http%3A%2F%2F0.0.0.0%2F
Filter chain halted as :check_if_login_required rendered or redirected
Completed 302 Found in 60ms (ActiveRecord: 3.7ms)
App 179 stdout:
Started GET "/login?back_url=https%3A%2F%2Fredmine.mydomain.tld%2F" for 95.90.204.176 at 2018-03-14 19:10:26 +0000
Processing by AccountController#login as HTML
Parameters: {"back_url"=>"https://redmine.mydomain.tld/"}
Current user: anonymous
Rendered account/login.html.erb within layouts/base (24.1ms)
Completed 500 Internal Server Error in 219ms (ActiveRecord: 4.3ms)
ActionView::Template::Error (undefined method `default_users_time_zone' for #<Class:0x00000000055f2120>
Did you mean? default_users_hide_mail):
11: <%= favicon %>
12: <%= stylesheet_link_tag 'jquery/jquery-ui-1.11.0', 'application', 'responsive', :media => 'all' %>
13: <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
14: <%= javascript_heads %>
15: <%= heads_for_theme %>
16: <%= call_hook :view_layouts_base_html_head %>
17: <!-- page specific tags -->
app/models/user_preference.rb:44:in `initialize'
app/models/user.rb:949:in `pref'
app/helpers/application_helper.rb:1451:in `javascript_heads'
app/views/layouts/base.html.erb:14:in `_app_views_layouts_base_html_erb__2446195152155203147_36658300'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
What could that be? I need to upgrade to 3.4 because I want to use a plugin but the plugin requires version 3.4 in use.
It was my fault! I did not copy every new settings file to my mounted config directory.

Error with JS.ERB file

I'm new into Rails world, and I'm trying to learn.
I'm following these tutorial: http://www.noupe.com/development/create-a-simple-twitter-app.html and trying to create an simple twitter application.
All code can be found in https://github.com/ricardovsilva/twitter-rubyOnRails .
I'm trying to add some ajax and javascript functionallity to my app and I'm having a lot of issues (and some of they I'm able to deal with google searchs) because tutorial is in rails 2 and I'm using rails 4.
The line of tutorial I'm stucked is:
Finally, we need to create the rjs template. To do this, create a file called “create.js.rjs” in the views/posts folder and add the following code.
page.insert_html :top, :posts, :partial => #post
page[#post].visual_effect :highlight
The problem is, when my browser try to render the page that uses this JS, I get the following error : "Uncaught SyntaxError: Unexpected token"
By the way, I'm using google chrome. To simulate the error just clone the repo, access this and run rails server. Open browser and go to http://localhost:3000/posts . Page will render, but with one error (posts will not be loaded, only one textbox and one button).
I really don't know what to do to make the browser understand these rails commands.
Any help will be appreciated.
EDIT: This is all that appears on my terminal
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
[2015-02-28 15:01:33] INFO WEBrick 1.3.1
[2015-02-28 15:01:33] INFO ruby 2.1.5 (2014-11-13) [x64-mingw32]
[2015-02-28 15:01:33] INFO WEBrick::HTTPServer#start: pid=5872 port=3000
Started GET "/posts" for ::1 at 2015-02-28 15:01:39 -0300
ActiveRecord::SchemaMigration Load (1.0ms) SELECT schema_migrations.* FROM
schema_migrations
Processing by PostsController#index as HTML
Rendered posts/_message_form.html.erb (2.0ms)
Post Load (1.0ms) SELECT posts.* FROM posts ORDER BY posts.created_at
ASC
Rendered posts/_post.html.erb (13.0ms)
Rendered posts/index.html.erb within layouts/posts (52.0ms)
Completed 200 OK in 120ms (Views: 78.0ms | ActiveRecord: 16.0ms)
Started GET "/assets/create-3acb657a1c6a2ce4ccc5172e5bd59c6e.js?body=1" for ::1
at 2015-02-28 15:01:41 -0300
The file where error happens is the create.js.erb, that is saved into folder app/assets/javascript.
This is the content of file:
page.insert_html :top, :posts, :partial => #posts
page[#post].visual_effect : highlight
[Edit 2 - After #rubykid suggestion]
I'm calling these javascript (or trying) from the posts.html.erb, but now I'm having error on console.
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<%=javascript_include_tag :all%>
</head>
<body>
<div id="content">
<%= yield %>
</div>
</body>
</html>
It's appear like he's trying to get the "all.js" file, and he will not, because it's don't exists. (on terminal I get this line Started GET "/javascripts/all.js" for ::1 at 2015-02-28 15:44:04 -0300)
What is the correct syntax in ruby 4?

Rails ActionView::Template::Error on production

I have a Rails 4 app working in development, but when I deploy to a VPS with Capistrano, I get the following error:
INFO -- : Started GET "/" for ***.***.***.*** at 2013-12-20 22:24:28 +0000
INFO -- : Processing by PortalsController#index as HTML
INFO -- : Rendered portals/index.haml within layouts/application (2.9ms)
INFO -- : Completed 500 Internal Server Error in 7ms
FATAL -- :
ActionView::Template::Error (key not found: :params):
1: %h2
2: = link_to "New portal", new_portal_path
3:
4: %h3 Current portals:
5: = render #portals
app/views/portals/index.haml:2:in `_app_views_portals_index_haml___3074475544725108295_70221306145460'
In looking at differences between production.rb and development.rb, I discovered that setting
config.eager_load = false
in production.rb, the error goes away. However, I would like to keep the default setting of config.eager_load set to true. Does anyone have any ideas on why this would be happening?
portals_controller.rb
def index
#portals = Portal.all
end
portals/index.haml
%h2
= link_to "New portal", new_portal_path
%h3 Current portals:
= render #portals
portals/_portal.haml
%p
= link_to portal.name, portal
config/routes.rb
******::Application.routes.draw do
root to: 'portals#index'
resources :portals, shallow: true do
resources :webpages do
resources :documents
end
end
mount Resque::Server, at: "/resque"
end
I'm using unicorn and nginx on the VPS.

Rails strange behavior of production app running on heroku

In user model I've got attribute location of type point. Now I've got a validation code:
validates :location, :format => { :with => /\(-?\d+(?:\.\d+)?,-?\d(?:\.\d+)?\)/,
:on => :update,
:if => :location_changed? }
It works fine in console, on localhost, but on heroku it returns:
Processing by UsersController#update as / 2012-07-31T18:14:37+00:00
app[web.1]: Parameters:
{"user"=>{"location"=>"(3.545452,2.4353534)"}, "id"=>"self"}
2012-07-31T18:14:37+00:00 app[web.1]: Completed 500 Internal Server
Error in 13ms 2012-07-31T18:14:37+00:00 app[web.1]:
2012-07-31T18:14:37+00:00 app[web.1]: NoMethodError (undefined method
location_changed?' for #<User:0x00000004dc29c8>):
2012-07-31T18:14:37+00:00 app[web.1]:
app/controllers/users_controller.rb:16:inupdate'
Actually it works also great in heroku console, but don't work in curl request.
Rails version 3.2.7.
attr_accessible :profile_picture, :password, :location
Thanks!
It looks like a magic. I fixed it with recreation if table and server restart. Very strange.

How to cache HAML files in /tmp directory?

I'm having an issue with HAML where it is attempting to write to a read-only filesystem (on a Heroku-deployed app).
I can only write to /tmp and /log. How can I configure HAML to write files to the /tmp directory?
Thanks!
Edit:
Output of actual error
Started GET "/" for <ip> at Sun Oct 03 13:19:42 -0700 2010
Processing by WelcomeController#index as HTML
Rendered welcome/index.html.haml within layouts/application (5.6ms)
Completed in 10ms
ActionView::Template::Error (Read-only file system - /disk1/home/slugs/305306_d9977a4_8922/mnt/public/stylesheets/.permissions_check.23729009697080.19743.369932 - Heroku has a read-only filesystem. See http://docs.heroku.com/constraints#read-only-filesystem):
3: %html
4: %head
5: %title= title
6: = stylesheet_link_tag "reset", "application", "grid", :cache => "base"
7: = javascript_include_tag :defaults
8: = csrf_meta_tag
9:
app/views/layouts/application.html.haml:6:in `_app_views_layouts_application_html_haml___661334860_23729045526060_0'
Like Mark commented, I think you mean SASS, not Haml. Here's how to use git commit-hooks to precompile your SASS before deploying to heroku.
EDIT: After full error was posted
Change
= stylesheet_link_tag "reset", "application", "grid", :cache => "base"
to
= stylesheet_link_tag "reset", "application", "grid"
The caching isn't HAML, it's RAILS, and it's doing this on first read.

Resources