Comments in Ruby and JavaScript

Ruby Comments There are basically two types of comments in Ruby. And they work in the same way as follows: The block comment The comment block is created with the =begin and =end delimiters. def welcome =begin This will print the welcome message. You can also add your custom message. =end puts "Welcome to ruby comments learning :)" end The line comment This is the simple comment where you place an octothorpe(#) as the first non-whitespace character of the line, and everything else written is excluded from being interpreted by Ruby. def welcome # This will print the welcome message.

Be cautious with 'display: none' style

Most of the time, we use display: none property to hide the elements from out HTML page. Reference: http://www.w3schools.com/css/css_display_visibility.asp But this property might make you bang your head, if you are adding any event to the elements having this property. Yeah, recently we faced some strange issue in our ember-application. We have a image-upload feature in application. For that we have added a button "Add Image" and a file input. The file input we kept hidden and on click of the button "Add Image", we were triggering click

Photo upload from phone-gallery or phone-camera in Ember-Cordova Application

Currently am working on Ember Application, and for the same we have also developed cordova application using ember-cli-cordova plugin https://github.com/poetic/ember-cli-cordova In this application, we have a photo upload feature. Using cloudinary.js, we upload it directly to cloudinary on photo-selection. In web-application, we have added a hidden file input field, and on-click of "Add Image" button, we triggered click event on that file-input. In Cordova-App, It works fine and just allows us to upload images from phone-gallery, but does not allows us to use phone-camera to take a pic and upload it. (Note: In

Ember.js: How to track last visited route?

Recently, I added a global search feature in out Ember Application. As it was a global search, it was linked from most of the pages of the application. User can click on search icon in the right-top corner and he will be redirected to search page. But now how to go back to the page we came from? as User can go to search from any of the page of the application. Here we will see how we can know about last visited route in ember application. We can find our previous route as follows: import Ember from 'ember'; export

Ember.js: Create link to div on another page using link-to helper

In simple html pages, we can easily create link to div tag or any other tag on same page and even on different pages. For example: Heading Text Refer it as: Link text Now how we can achieve it in Ember.js using {{link-to}} helper? Lets take as example: -> Consider we have a page "/faq" and it has following content: faq.hbs .. What kinds of items can be donated? .. -> Now we want to visit page "faq" and scroll it down to the above question. -> Simply, we can achieve it using

Launch your website as mobile web application

Are you looking for way to launch your website as a web-app for mobile users? Yes it's possbile.. Recently, I am developing an ember.js application. We are using ember.js (using ember-cli) in our client application and in backend we are using ruby-on-rails. Here we are designing our ember app for mobile users, developing it's UI more responsive for all mobile, tablet and desktop users. Now along with that we want our users to use it like a web-application instead of just browsing it on mobile-browsers. So we did it in following: For Android Users: In your main page

Routing in Ember.js

One of the distinguishing features of Ember is the heavy emphasis it puts on URLs. In many other frameworks, having separate URLs for separate screens is either lacking or is tacked on as an afterthought. In Ember, the router is the component that manages urls and transitions between them. Ember Routing Guides: http://emberjs.com/guides/routing/(link) Ember.Route class details: http://emberjs.com/api/classes/Ember.Route.html(link) Here we will take a look at different ways of adding routes: Dynamic Segments in Routes: A dynamic segment is a portion of a URL that starts with a

Ember Computed Properties

Ember computed property is the most powerful thing ember has and here we are going to get overview of how we can make use of these properties. Ember guides has explained it very nice way, and here I would like to add some more.. Bind property to nested resources Many times we need to depend on nested resources for ex: Find the count of comments or likes for post OR find number of items in cart etc. Here we want to update property as its nested resource is changed. Consider example: here we have property itemCount on cart, which should

Send notification to flowdock-group from rails application

If you want to send any notification message from your rails application, its easy to send it with following steps: To send notification to your flowdock group, you will need email-address of flowdock grouYou can get it from flow-settings of your group. example: "xxxx@xxxx.flowdock.com" In your application, define mailer class and send email-message to above email. class UserMailer Thanks.

Numeric input in Ember.js

Easy way to create a numeric input, which accepts only numbers (i.e. 0-9 and no other characters). app/components/numeric-input.js import Ember from 'ember'; export default Ember.TextField.extend({ tagName: "input", type: "number", attributeBindings: [ "name", "type", "value", "maxlength", "id" ], keyDown: function(e) { var key = e.charCode || e.keyCode || 0; // allow enter, backspace, tab, delete, numbers, keypad numbers, home, end only. return ( key === 13 || key === 8 || key === 9 || key === 46 || (key >= 35 && key = 48 && key = 96 && key And in your template, call it as {{numeric-input value=mobilePhone name="mobilePhone" id="mobile" maxlength="8" }} As the number input displays up