http://en.wikipedia.org/wiki/Luhn_algorithm
Implement a Ruby program that outputs the validity of a number by applying the Luhn Checksum.
The program should accept a single number to validate.
| $(document).ready(function() { | |
| function hideHeader() { | |
| $("#headerBox").animate({height: default_height}, speed, function(){ | |
| $(".securekey_toggle").show("drop"); | |
| }); | |
| $("#headerAnimateWrapper").hide(); | |
| } | |
| $(".testtoggle").click(function() { |
http://en.wikipedia.org/wiki/Luhn_algorithm
Implement a Ruby program that outputs the validity of a number by applying the Luhn Checksum.
The program should accept a single number to validate.
| class Duck | |
| attr_accessor :quack | |
| def initialize(with_quack) | |
| self.quack = with_quack | |
| end | |
| def get_angry_tubbo | |
| self.quack | |
| end |
| <!-- code removed as not relavent --> | |
| <div class="tab-pane fade in" id="specs"> | |
| <%= render :partial => 'secure/specifications/form' %> | |
| </div> | |
| <!-- code removed as not relavent --> | |
| class DeejaysController < ApplicationController | |
| # GET /deejays | |
| # GET /deejays.json | |
| def index | |
| @deejays = Deejay.all | |
| respond_to do |format| | |
| format.html # index.html.erb | |
| format.json { render json: @deejays } |
| class ContestEntriesController < ApplicationController | |
| def create | |
| @contest_entry = ContestEntry.new(params[:contest_entry]) | |
| @contest_entry.save | |
| redirect_to root_path | |
| end |
| class Problem < ActiveRecord::Base | |
| attr_accessible :body, :title | |
| validates :title, length: { minimum: 3 } | |
| end |
| My problem is that I'm not sure the approach is the right one, although, it respects the patterns of MVC. | |
| In the end, I gent the following error: | |
| #<NoMethodError: undefined method `formats' for nil:NilClass> | |
| org/jruby/RubyKernel.java:227:in `method_missing' | |
| I don't really understand what format has to do with this. I tried to return both :layout => true and :layout => false, but I got the same error. | |
| So the approach is as follows: |
| def get_auth | |
| self.authentications.reduce({}) { |auths,auth| auths[auth.provider] = auth.id } | |
| end |
| // Validates a single input | |
| function validate(input) { | |
| if (!input.getAttribute('required')) { return false; } | |
| (!input.value) ? new Error(input.name + "is required.") : true | |
| } | |
| // Takes in an array of inputs, and tells us if they're all valid or no | |
| function isFormInvalid(inputs) { | |
| return inputs.map(validate) // Validates all fields | |
| .filter(Boolean) // Keeps only the errors |