As I am working to get ember running I am now failing to get my handlebar templates to load through asset pipeline.
I'm using the handlebars_assets gem, and when I hit the server I get what is below, I verified that the path is correct, but not really sure how to fix this.
When I require handlebars.runtime:
couldn't find file 'handlebars.runtime'
(in /Users/tspore/Rails/Active/tombfinder/app/assets/javascripts/app/ember_app.js:1)
Cache read: sprockets/6f42a4ba0f2b80167ce50f9f306427fa
Compiled app/ember_app.js (5ms) (pid 9791)
Cache read: sprockets/764613d8100bb6d8e6072701f79183c1
Completed 500 Internal Server Error in 141ms
ActionView::Template::Error (can't convert nil into String
(in /Users/tspore/Rails/Active/tombfinder/app/assets/javascripts/app/templates/records/index.hbs)):
26: <% end %>
27:
28:
29: <%= javascript_include_tag 'app/ember_app' %>
30: </head>
31: <body class="<%= #class %>">
32: <div id="center">
app/views/layouts/js.html.erb:29:in `_app_views_layouts_js_html_erb__854441834177334479_70351597254240'
app/controllers/js/js_controller.rb:3:in `index'
Rendered /Users/tspore/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.1.10/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
Rendered /Users/tspore/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.1.10/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.6ms)
Rendered /Users/tspore/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.1.10/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (3.0ms)
EDIT: After using Github version, and removing the gem from the :assets - it seems to work. But now I am getting this error -
Uncaught ReferenceError: HandlebarsTemplates is not defined records_view.js:4
Uncaught Error: assertion failed: Unable to find view at path 'App.listRecordsView'
My application looks like this -
App.listRecordsView = Ember.View.extend({
templateName: HandlebarsTemplates['records/index'](context)
});
with the ember-rails gem I got the gem to compile so now I have a script called layout.js which looks like this:
Ember.TEMPLATES["app/templates/controller/layout"] = Ember.Handlebars.template(function anonymous(Handlebars, depth0, helpers, partials, data) { helpers = helpers || Ember.Handlebars.helpers; data = data || {};
var buffer = '', stack1, hashTypes, escapeExpression=this.escapeExpression;
data.buffer.push("<h1>from template</h1>\n");
stack1 = {};
hashTypes = {};
stack1 = helpers._triageMustache.call(depth0, "outlet", {hash:stack1,contexts:[depth0],types:["ID"],hashTypes:hashTypes,data:data});
data.buffer.push(escapeExpression(stack1) + "\n");
return buffer;
});
How do I call this template in the Ember App? It has no name space to say:
templateName: 'layout'
Related
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.
I am testing out the service-worker rails gem and am using VAPID private and public keys to send push notifications. I've succesfully been able to create push notifications locally, but when I deploy to heroku, the app raises the error stated above when trying to go to the push notification page. Here is the error:
75] Started GET "/push-simple/" for 69.253.120.203 at 2017-02-12 06:37:35 +0000
2017-02-12T06:37:35.339318+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] ActionView::Template::Error (undefined method `tr' for nil:NilClass
2017-02-12T06:37:35.333379+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] Rendering pages/push-simple.html.erb within layouts/application
2017-02-12T06:37:35.332337+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] Processing by PagesController#show as HTML
2017-02-12T06:37:35.336377+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] Rendered pages/push-simple.html.erb within layouts/application (2.8ms)
2017-02-12T06:37:35.336998+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] Completed 500 Internal Server Error in 4ms
2017-02-12T06:37:35.339281+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75]
2017-02-12T06:37:35.339490+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] 13: <script type="text/javascript">
2017-02-12T06:37:35.339320+00:00 app[web.1]: Did you mean? try):
2017-02-12T06:37:35.339489+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] 11: </div>
2017-02-12T06:37:35.339489+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] 12:
2017-02-12T06:37:35.339561+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] app/views/pages/push-simple.html.erb:14:in `_app_views_pages_push_simple_html_erb__2838769268823495646_39526220'
2017-02-12T06:37:35.339491+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] 15: </script>
2017-02-12T06:37:35.339491+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] 14: var publicKey = new Uint8Array(<%= WebpushClient.public_key_bytes %>);
2017-02-12T06:37:35.339492+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] 16: <%= javascript_include_tag 'push-simple' %>
2017-02-12T06:37:35.339520+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75]
2017-02-12T06:37:35.339560+00:00 app[web.1]: [3d626b62-4c1b-41ca-aad3-fc653dc96b75] app/clients/webpush_client.rb:7:in `public_key_bytes'
And here is my webpushclient where the VAPID keys are defined:
class WebpushClient
def self.public_key
ENV['VAPID_PUBLIC_KEY']
end
def self.public_key_bytes
Base64.urlsafe_decode64(public_key).bytes
end
def self.private_key
ENV['VAPID_PRIVATE_KEY']
end
# Send webpush message using subscription parameters
#
# #param message [String] text to encrypt
# #param subscription_params [Hash<Symbol, String>]
# #option subscription_params [String] :endpoint url to send encrypted message
# #option subscription_params [Hash<Symbol, String>] :keys auth keys to send with message for decryption
# #return true/false
def send_notification(message, endpoint: "", p256dh: "", auth: "")
raise ArgumentError, ":endpoint param is required" if endpoint.blank?
raise ArgumentError, "subscription :keys are missing" if p256dh.blank? || auth.blank?
Rails.logger.info("Sending WebPush notification...............")
Rails.logger.info("message: #{message}")
Rails.logger.info("endpoint: #{endpoint}")
Rails.logger.info("p256dh: #{p256dh}")
Rails.logger.info("auth: #{auth}")
Webpush.payload_send \
message: message,
endpoint: endpoint,
p256dh: p256dh,
auth: auth,
vapid: {
subject: "jon.corrin#gmail.com",
public_key: public_key,
private_key: private_key
}
end
def public_key
self.class.public_key
end
def private_key
self.class.private_key
end
end
and here is the script im using to call the public key:
<script type="text/javascript">
var publicKey = new Uint8Array(<%= WebpushClient.public_key_bytes %>);
</script>
<%= javascript_include_tag 'push-react' %>
Like I said before, it works locally. I think I may have forgotten to define a variable, I've looked at similar posts and have been debugging for quite some time, but have had no luck. Any suggestions? I also want to add, I'm quite new, so if it's an obvious error, I'll completely understand.
Your error is coming from this method:
def self.public_key_bytes
Base64.urlsafe_decode64(public_key).bytes
end
Looking up the source code for Base64#urlsafe_decode64, this is defined by:
def urlsafe_decode64(str)
strict_decode64(str.tr("-_", "+/"))
end
This is where your undefined method 'tr' for nil:NilClass must be coming from: the public_key. Which you have defined by:
def self.public_key
ENV['VAPID_PUBLIC_KEY']
end
...In other words, you have not set the environmental variable on your production server. That's why it works locally, but not on production.
I made a mistake before migrating a plugin, and have written
flash[:notice] = :label_presta_added
instead of
flash[:notice] = l(:label_presta_added)
I corrected my mistake but it seems that my Redmine Plugin has trashed my Redmine. Even though I delete my plugin a migrate once again, I still get this error:
Started GET "/" for 127.0.0.1 at 2016-06-01 22:21:37 +0200
Processing by WelcomeController#index as HTML
Current user: admin (id=1)
Rendered welcome/index.html.erb within layouts/base (28.1ms)
Completed 500 Internal Server Error in 366ms (ActiveRecord: 116.0ms)
ActionView::Template::Error (undefined method `html_safe' for :label_presta_added:Symbol
Did you mean? html_safe?):
97: <div id="sidebar">
98: <%= yield :sidebar %>
99: <%= view_layouts_base_sidebar_hook_response %>
100: </div>
101:
102: <div id="content">
103: <%= render_flash_messages %>
app/helpers/application_helper.rb:312:in `block in render_flash_messages'
app/helpers/application_helper.rb:311:in `render_flash_messages'
app/views/layouts/base.html.erb:100:in `_app_views_layouts_base_html_erb__4104276684161420982_39604440'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Can somebody give me a hand here?
Thanks in advance!
This is stored in your session, so usually changing the session secret key will invalidate all sessions and discard any old session data.
You can also try and rescue to clear it out as a one-time deal.
Have you restarted the server? Or you can use flash[:notice] = nil to remove it.
It looks like it throws a html_safe error. Can you see if the method which is rendering the flash is using html_safe? It looks like its coming from there.
Not sure exactly, may be shooting in the dark.
But read these and try may be:
actionview::template::error(undefined method 'html_safe' for nil:NilClass)
http://www.redmine.org/issues/8477
I have two different sets of CSS files that I want to use for the same website hosted with heroku.
The first set of CSS files are the standard Twitter BootStrap CSS files converted to SASS.
The second set are custom settings for my application.
I have been able to get the look and feel right on my development server but when I upload it to heroku the output is just
<body>
<head>
</head>
</body>
Please help!
My site is configured as such:
http://imgur.com/S5Aoov1&V3RNQZ3&lSJqpCz&jdSfy82
My controlling layout file is:
doctype 5
html data-uuid=current_user.try(:id)
= render 'head'
= render 'third_party_scripts'
body class=controller_name
= render 'navbar'
= render partial: 'account/infobar'
.container
= render partial: 'flash', locals: { flash: flash }
= yield
I've duplicated this file and named it "_home.html.slim"
I've changed the contents to:
head
title = t('.title', default: 'My Winning Trade')
= stylesheet_link_tag 'home', media: 'all'
= stylesheet_link_tag 'justified-nav', media: 'all'
= stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Shanti|Open+Sans:400,700,800'
= javascript_include_tag 'jquery'
= csrf_meta_tags
The CSS for my landing pages are called home & justified-nav, based on the jumbotron example provided by twitter bootstrap. http://getbootstrap.com/examples/jumbotron/
Heroku Error logs after Asset Precompile:
2013-10-04T19:48:42.124903+00:00 app[web.1]: Completed 500 Internal Server Error in 384ms
2013-10-04T19:48:42.127966+00:00 app[web.1]: 3: = stylesheet_link_tag 'home', media: 'all'
2013-10-04T19:48:42.127966+00:00 app[web.1]:
2013-10-04T19:48:42.127966+00:00 app[web.1]: 1: head
2013-10-04T19:48:42.127966+00:00 app[web.1]: app/views/layouts/sessions.html.slim:3:in `_app_views_layouts_sessions_html_slim__3803347664834042281_69939052542640'
2013-10-04T19:48:42.127966+00:00 app[web.1]: 2: title = t('.title', default: 'My Winning Trade')
2013-10-04T19:48:42.128146+00:00 app[web.1]:
2013-10-04T19:48:42.127966+00:00 app[web.1]: ActionView::Template::Error (home.css isn't precompiled):
2013-10-04T19:48:42.127966+00:00 app[web.1]: 4: = stylesheet_link_tag 'justified-nav', media: 'all'
2013-10-04T19:48:42.127966+00:00 app[web.1]: 5: = stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Shanti|Open+Sans:400,700,800'
2013-10-04T19:48:42.127966+00:00 app[web.1]: 6: = javascript_include_tag 'jquery'
2013-10-04T19:48:42.127966+00:00 app[web.1]: app/views/application/_home.html.slim:3:in `_app_views_application__home_html_slim___3730913017080964654_69939053460220'
2013-10-04T19:48:42.128146+00:00 app[web.1]:
I'm not sure I completely understand what you're asking. But it sounds like:
You have a single layout file.
You want to load a single set of stylesheets in one set of views
In another set of views, you want to additionally load a second stylesheet.
Is that correct? If so, couldn't you just do something like this in your layout:
doctype 5
html data-uuid=current_user.try(:id)
= render 'head'
= render 'head_foobar' if controller_name == 'foobar'
The issue ended up being the home.css file not compiling on the heroku server side.
By changing the production.rb file setting:
from:
config.assets.compile = false
to:
config.assets.compile = true
The layout configuration that #Manishie suggested worked!
Thank you everyone!
This is an issue I have been working around for some time now thinking I would eventually stumble on an explaination. I have not and it's now becoming a little more problematic for me.
I used rails-generate-scaffold to create a simple (users and posts) application. This was done after installing jquery and jquery-ui. I added actions "login" and "auth" to the users controller. Login.html.erb contains some javascript that sends .ajax request to the users#auth action passing the login information (email and password) as parameters.
The the template auth.js.erb exists. The "auth" action responds to format.js. The request looks normal, but rails processes the request with the "show" action rather than the "auth" action.
In other words, a request to userscontrollers#auth (via .ajax) is being processed by userscontroller#show (as JS).
The problem goes away if I remove the "resources :users" route that scaffold added (the correct action is then called). But without this route other useful scaffold stuff becomes unuseable (like users#new).
From Gemfile: gem 'jquery-rails', '>=0.2.6'
Installed jQuery with: rails generate jquery:install --ui
From ../layouts/application.html.erb
<head>
<title>Tab1</title>
<%= stylesheet_link_tag :all %>
<%= stylesheet_link_tag 'jquery-ui-1.8.16.custom.css' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag 'jquery.min.js' %>
<%= javascript_include_tag 'jquery.min.js', 'jquery-ui.min.js' %>
<%= csrf_meta_tag %>
</head>
Here is ./log/development.log to shows the request and the response.
Started GET "/users/auth/?email=steve&password=[FILTERED]&_=1326063255777" for 24.11.242.181 at 2012-01-08 17:53:45 -0500
Processing by UsersController#show as JS
Parameters: {"email"=>"steve", "password"=>"[FILTERED]", "_"=>"1326063255777", "id"=>"auth"}
^[[1m^[[36mUser Load (0.2ms)^[[0m ^[[1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 0 LIMIT 1^[[0m
Completed 404 Not Found in 6ms
ActiveRecord::RecordNotFound (Couldn't find User with ID=auth):
app/controllers/users_controller.rb:43:in `show'
Suggests that the request --> GET "/users/auth/?email ... is being processed by UsersController#show as JS
Thanks