coffeescript

Meteor mail not sending despite setting MAIL_URL environment variable

天涯浪子 提交于 2019-12-24 13:16:15
问题 I'm getting this error message in the terminal "Mail not sent; to enable sending, set the MAIL_URL environment variable." despite setting MAIL_URL environment variable. After this message the whole mail content html gets dumped in the terminal. I'm using 2 meteor packages for sending email: yogiben:pretty-emails and email with mailgun api service. Here's the source code for the mail config and sending email: if Meteor.isServer Meteor.startup -> process.env.MAIL_URL = 'smtp://sandboxid.mailgun

Rails 3.1 CoffeeScript/JQuery - How to change the source of an image in a div?

有些话、适合烂在心里 提交于 2019-12-24 12:51:44
问题 I would like to change the image of a link with jquery. This is what I tried : In my Haml file : .selected = link_to image_tag('/assets/unselected.png'), {:controller => Posts, :action => "update", :selected => true}, :id => "selected_post", :remote => true, :method => :put After some stuff in my posts_controller, here is the update.js.coffee where I tried to change the image of the link with a new one called selected.png : $("selected_post").attr 'src', '/assets/selected.png' I does not work

How do i build html inside .js.haml file?

懵懂的女人 提交于 2019-12-24 10:58:33
问题 I am wondering how to eloquently return the following call in my ajax call? Where i can have break lines etc inside the append function? $(".q#{@question_id}.result_to_response") .html("#{escape_javascript(@resp)}") .append('<div><a href="#" class="continue_button">Continuez to next question</a></div>'); 回答1: My advice to you is just use jQuery templates or smthng similar for that. This way you easily generate all your templates with haml and then just append .tmpl() return value in html body

no_file_data error when using Slack API upload

扶醉桌前 提交于 2019-12-24 10:49:45
问题 I'm getting this error {"ok":false,"error":"no_file_data"} when I try to call the slack API to upload. I already have the specified file in ./log. robot.respond /upload (.*)/i, (res) -> app_name = res.match[1] request = require("request") fs = require("fs") channel_name = res.message.room data = { channels: channel_name, filename: "#{app_name}.txt", file: fs.createReadStream("./log/#{app_name}.txt"), } robot.http("https://slack.com/api/files.upload") .headers(Authorization: 'Bearer slack

Any idea not to select the name that is already chosen in token input?

…衆ロ難τιáo~ 提交于 2019-12-24 10:11:28
问题 Is there any idea not to select the name that is already chosen in token input? For example In first I select mango when I search for m. Next time again when I search for m Mango should not be displayed as mango is already chosen. Is there any idea? <%= f.text_field :plan_tokens, data: {load: @customer.plans} %> I have my js like this jQuery -> $('#customer_plan_tokens').tokenInput '/plans.json' theme: 'facebook' prePopulate: $('#customer_plan_tokens').data('load') where to put

Meteor errors internationalization

我的未来我决定 提交于 2019-12-24 08:18:31
问题 I'm trying to implement internationalization through just-i18n and it works fine so far. Problem is I'm also using accounts-password and especially Meteor.loginWithPassword(user, password, [callback]). On login error, the callback has an error object that basically looks like this : { details: undefined, error: 403, errorType: "Meteor.Error", message: "User not found [403]", reason: "User not found" } I thought the error code was unique and went with a i18n configuration file like this : i18n

Alert function not working in coffeescript

穿精又带淫゛_ 提交于 2019-12-24 07:03:13
问题 I found about CoffeeScript in a blog and decided to give it a try ,my first project/code with it was this alert "Hello CoffeeScript!" It doesn't work and gives this reply ReferenceError: alert is not defined is there anything i am doing wrong? 回答1: JavaScript is a language which is strongly tied to the concept of environments . A browser and Node.js are two possible environments to run JS code (CoffeeScript compiles to JavaScript). When JavaScript is embedded in a browser, the global object

Playing sound in rails

ぐ巨炮叔叔 提交于 2019-12-24 06:51:19
问题 I'm currently using coffeescript to play wav file I'm using this code below to play sound file * *my Coffeescript audio = new Audio('error.wav'); audio.play(); I put error.wav in /app/assets/audio/error.wav rails generate an error Started GET "/touchtypings/error.wav" for 127.0.0.1 at 2014-01-28 11:08:04 +0700 Processing by TouchtypingsController#show my understanding when it run the script rails is trying to interprett error.wav as route and process in controller I just want to play the wav

Coffeescript - 'this' is always replaced by '_this' in fat arrow callback

爷,独闯天下 提交于 2019-12-24 02:45:22
问题 I'm wondering is possible somehow to prevent this keyword to be transformed into _this inside fat arrow callback ( => )? For example: class someClass someMethod: -> $(document).on 'click', '.myclass', (e) => # doing things with right context this, it's ok @anotherMethod() @oneMoreMethod() # but here I need jQuery ``this`` pointing to element $el = $ this # this is transformed into ``_this`` :( Maybe I missed some option or operator? UPDATE I know about the trick like self = this , but I

Static url to asset

。_饼干妹妹 提交于 2019-12-24 02:42:09
问题 I have a script my_pub_script.js.coffee written with coffeescript and I want to make it public so anybody can download it on example.com/scripts/my_pub_script.js I can put any files in /public but this is coffee and I had to pass it through asset pipeline to properly compile it to js . But if I compile my script it will have a name with fingerprint suffix like my_pub_script-e55bd5e3eb82fa4e8034af2883dc37e8.js so I don't know the current link to it. Sure I have many other files that I want to