Saturday, October 1, 2016

Rails 4 - Stripe webhook 500 error | Fixed issues

Rails 4 - Stripe webhook 500 error | Fixed issues


Rails 4 - Stripe webhook 500 error

Posted: 01 Oct 2016 07:21 AM PDT

 #stripe_controller.rb     class StripeController < ApplicationController     protect_from_forgery except: :stripe_webook       skip_before_action :verify_authenticity_token           def stripe_webook        data_json = JSON.parse(request.body.read)        event_id = data_json['id']        data = Stripe::Event.retrieve(event_id)        handle_webhook(data)        head :ok     end  

Only getting a 500 error when testing webhooks via Stripe dashboard, however using curl

curl -i     -H "Content-Type: application/json"              -X POST -'{"id":"evt_0000000000000001","object":"event","api_version":"2016-03-07","created":1475273919,"data":{"object":{"id":"in_xxxxxxxxxxxxxxxxxxx","object":"invoice","amount_due":2900,"application_fee":null,"attempt_count":1,"attempted":true,"charge":"ch_xxxxxxxxxxxxxx","closed":false,"currency":"usd","customer":"cus_xxxxxxxxxxxx","date":1475270308,"description":null,"discount":null,"ending_balance":0,"forgiven":false,"lines":{"object":"list","data":[{"id":"sub_xxxxxxxxxxx","object":"line_item","amount":2900,"currency":"usd","description":null,"discountable":true,"livemode":false,"metadata":{},"period":{"start":1475270272,"end":1477862272},"plan":{"id":"tier_a_plan","object":"plan","amount":2900,"created":1475099850,"currency":"usd","interval":"month","interval_count":1,"livemode":false,"metadata":{},"name":"Startup","statement_descriptor":null,"trial_period_days":15},"proration":false,"quantity":1,"subscription":null,"type":"subscription"}],"has_more":false,"total_count":1,"url":"/v1/invoices/in_xxxxxxxxxxxxxxxx/lines"},"livemode":false,"metadata":{},"next_payment_attempt":1475360318,"paid":false,"period_end":1475270272,"period_start":1475269805,"receipt_number":null,"starting_balance":0,"statement_descriptor":null,"subscription":"sub_xxxxxxxxxxxxxxx","subtotal":2900,"tax":null,"tax_percent":null,"total":2900,"webhooks_delivered_at":1475270308}},"livemode":false,"pending_webhooks":1,"request":null,"type":"invoice.payment_failed"}'     https://myurl.com/stripe/webhook  

I am getting 200

After searching for answers - I am lost.

Rails form_tag with RESTFul params

Posted: 01 Oct 2016 07:02 AM PDT

I'm having a new_words controller and now I want to have a 'search' action.

I want Rails to return list of search results when navigate to this link new_words/search/"search_word_here"

In my routes, I got this:

resources :new_words do          collection do                      get 'search/:word', action: :search, as: 'search'          end      end  

And in view I have a form with get method.

<%= form_tag search_new_words_path, method: :get, remote: true do %>      <%= text_field_tag :word %>      <%= submit_tag 'Search' %>  <% end %>  

But I only get this error:

enter image description here

Thanks for any help :)

Rails and Heroku: How to add records to database?

Posted: 01 Oct 2016 07:02 AM PDT

I am new rails. I've developed a new app which shows image logos and my database contain url for these images-

In my local development environment I've added records into the database manually. My migration file for creation table looks like as follows-

class CreateBooks < ActiveRecord::Migration[5.0]  def change  create_table :books do |t|    t.string :title    t.string :author    t.string :category    t.text :description    t.text :logo_url    t.string :pdf_file_url      t.timestamps  end  

end

Controller-

def get_all_books  # @books = Book.find(2);  @books = Book.where(:id => 1..3)  logger.debug(@books.inspect)  render :json => @books  

end

My question is there any other way to add records to my books table?

And when I deploy my app to heroku how to add these records to heroku also?

Heroku An unhandled lowlevel error occurred. The application logs may have details

Posted: 01 Oct 2016 06:36 AM PDT

I got this error when I try to open my localhost:3000 after I deploy my website to heroku. Any idea?

An unhandled lowlevel error occurred. The application logs may have details.

I have my secret key and pasted but i still got the error

production: secret_key_base: b26fe2d2d606d4ad057466e139b625d5f187b3bcc812d5f83a74a6209c13c7f6282f3140a4adac740edbd5854089b8acfe30fbad30ed7c576f876a9a397b53fc

Rails Form accept only integer

Posted: 01 Oct 2016 06:39 AM PDT

This might be a noobisch question but I have a number_field that can only accept a value between 3 and 5 and only whole numbers(integer).

Now I've managed to get the range right with max and min but i can still fill in 3,5 for example.Is there any way to set this up?

I've been looking at the documentation but can't find annything, also I don't want to use any gems like simple_form because of a template I use.

MySQL Error "The server quit without updating PID file"

Posted: 01 Oct 2016 06:21 AM PDT

All. I am an absolute beginner of ruby on rails and web development.

Due to a lack of my knowledge about web development, I have been struggling one error for weeks, which is . ERROR! The server quit without updating PID file /usr/local/var/mysql/xxxxxxx.local.pid).

I just have no idea what to do anymore. Here is a list of my attempts to solve the error.

(1) ps aux | grep mysql

2667   0.0  0.0  2423376    204 s001  R+   10:04PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysql`    sudo kill -9 2667  kill: 2667: No such process  

(2) ls -la /usr/local/var/mysql to check who has an ownership of /usr/local/var/mysql

However, the error message

ls: /usr/local/var/mysql: No such file or directory

comes out.

I have read many articles that might help me solve the error in both my mother language and english. However, I have not gotten any single clue. Somebody PLEASE HELP ME!!

English is not my first language, so if this post need more information or does not make sense to you, please let me know. Any advice would be appreciated! Thank you very much in advance!

React js with browserify and bootstrap raising error

Posted: 01 Oct 2016 06:17 AM PDT

I have created a Rails application and installed react-rails. I also installed browserify-rails to help me manage external react packages.

My whole setup seems to work well, but when I try to use the react-bootstrap package's modal component, I am presented with a firebug error which seems to block all other js from executing. The error reads:

Uncaught Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs....

I have tried numerous possible solutions, but no luck. I don't really understand why I'm getting the error and why it's only happening on specific components such as the . If I use a normal html modal, there is no error. Here is my setup:

package.json

{    "name": "my_project",    "devDependencies": {      "browserify": "^13.1.0",      "browserify-incremental": "^3.1.1",      "reactify": "^1.1.1"    },    "license": "MIT",    "engines": {      "node": ">= 0.10"    },    "dependencies": {      "react": "^15.3.2",      "react-bootstrap": "^0.30.3",      "react-dom": "^15.3.2"    }  }  

application.js

//= require jquery  //= require jquery_ujs  //= require jquery-ui  //= require react  //= require react_ujs  //= require components  //= require_tree .    var React = window.React = global.React = require('react');  var ReactDOM= window.ReactDOM = global.ReactDOM = require('react-dom');  

application.rb

...  config.browserify_rails.commandline_options = "-t reactify --extension=\".js.jsx\""  ...  

components.js

// Setup app into global name space for server rendering  var app = window.app = global.app = {};    var MyComponent = require('./components/my_component');  app.MyComponent = MyComponent;  

my_component.js.jsx

var Modal = require('react-bootstrap').Modal;  var MyComponent = React.createClass({    render() {      return (        <Modal show={true}><h1>I'm working</h1></Modal>      )    }  });  module.exports = MyComponent;  

I am extremely new to react and I'm thus not sure whether this error has something to do with my setup or if it's something else?

How do view/edit queued jobs in Rails

Posted: 01 Oct 2016 05:43 AM PDT

I'm sending out an email but I need to view what is being queued. How to see that information.

rails g mailer DemoMailer  

Assuming all information is set properly, we now call the method:

DemoMailer.mail_method.deliver_later!(wait: 30.minutes)  

How to view that mail queue, in console?

Ive tried:

ActionMailer::DemoMailer.deliveries  

Using actioncable with rake tasks

Posted: 01 Oct 2016 05:12 AM PDT

I have an issue with using actioncable in rake tasks (Rails 5). In my controller I have this code:

subscription.users.each do |user|    NotificationsChannel.broadcast_to(user.email, message: 'blablabla')  end  

It works absolutely fine. Messages are sent to all the receivers. But I also need to use this broadcast logic in my rake task. I do this:

task show_delayed_tickets: :environment do    tickets = Ticket.where.not(delayed_to: nil)    tickets.each do |ticket|      subscription = ticket.subscription      subscription.users.each do |user|        NotificationsChannel.broadcast_to(user.email, message: 'blablabla')      end    end  end  

But it does not work. No exceptions. Receivers just don't get their messages. I think maybe I should include something into my raketask. Please help if you have some thoughts. Thanks

How to call st_setsrid postgis function from rails controller?

Posted: 01 Oct 2016 05:02 AM PDT

I'm creating a web app in Rails using postgres database with postgis extension. What I want is to create geometry from 2 coordinates in Rails controller method. I try to do this with following 2 commands:

sql = "SELECT ST_SetSRID(ST_Point(-71.1043443253471, 42.3150676015829),4326)"  geom = ActiveRecord::Base.connection.execute(sql)  

After the execution, I want that variable 'geom' is filled with the geometry. However, I receive following error:

Completed 500 Internal Server Error in 10ms (ActiveRecord: 4.6ms)  

Do you have any idea where could be the problem? Other postgis functions work fine with this way of quering. For example:

sql = "select st_x(st_transform(way,4674)), st_y(st_transform(way,4674)) from planet_osm_point where amenity like 'pub'"  

Rails Mongoid many to many does not add relation elements ids

Posted: 01 Oct 2016 05:02 AM PDT

I have 2 models

class Article    include Mongoid::Document      before_validation :find_tags      field :title, type: String      has_and_belongs_to_many :tags    accepts_nested_attributes_for :tags, :allow_destroy => true      def find_tags      self.tags = self.tags.map do |object|        Tag.find_or_initialize_by(:slug => Translit.convert(object.name, :english).downcase.gsub(/[^0-9a-z]/i, '-'), :name => object.name)      end    end  end    class Tag      include Mongoid::Document    field :name, type: String    has_and_belongs_to_many :articles  end  

Tags are nested attributes for articles. Before creating new tag I am checking if a tag with such name already exists and use it. the problem, is that for such fount tag article id will not be added in the article_ids array and this tag will have only one article id. Also it will be destroyed completely if I delete such tag from any article, but only article id should be removed from tag record because other articles may use it. Do you have any ideas what is wrong? Thanks!

Ruby on Rails, transform form data in url

Posted: 01 Oct 2016 04:57 AM PDT

i need some help for my application,I am creating an app using an api to search data relative to an username.

So i have done a form to type the username but on submit, i want the url to be like:

mydomain.com/search/myusername/ instead of mydomain.com/search?username=myusername

Because my route is : get 'players/:username', to: 'players#show'

Do you guys have any idea ?

Thanks a lot

on rails using ajax request with some time interval appending new records on table without browser refresh, missing template error

Posted: 01 Oct 2016 07:25 AM PDT

What i'm trying to achieve is to send a ajax request to a controller every few seconds and get all the latest record since last index page request then append it to that index page without browser refresh. I'm currently getting no template error even-though i have the required partial.

Here is route.

root 'leads#index'      resources :leads, only: [:index, :show] do        collection do          get 'fresh_leads'        end      end  

here is my controller

  def index      @leads = Lead.all      session[:last_refresh] = Time.current    end      def fresh_leads      @leads = Lead.where("created_at > ?", session[:last_refresh])      if @leads.present?        respond_to do |format|          format.html          format.js        end      end    end  

views/leads/fresh_leads.js.erb

<% if @leads.present? %>    $('lead-table-body').prepend('<%= j render :partial => 'fresh_leads' , leads: @leads %>')  <% end %>  

the partial

views/leads/_fresh_leads.html.slim

leads.each do |lead|      tr class="table-row" data-link="#{admin_lead_path(lead)}"      td = image_tag("icons/#{lead.lead_type}.png", class: 'lead-img-circle', data: { title: "#{lead.lead_type.titleize}" })      td.color-grey = number_with_delimiter(lead.id)      td.call_status data-title="#{lead.call_status}" class="circle lead-call-status #{lead.call_status_color}"      td.color-blue = lead.name      td.color-yellow = number_to_phone(lead.phone, area_code: true)      td = lead.email      td.color-grey = lead.upstream_name      td.min-width = lead.call_duration      td = lead.state      td.created_at = date_formatter(lead.created_at)      td.queued_at = date_formatter(lead.queued_to_dialing_list_at)      td.firstCalled_at = date_formatter(lead.first_called_at)      td.back_log = lead.backlog      td align="right"        = link_to "", lead_details_admin_lead_path(lead), remote: true, class: "show-right-panel fa fa-chevron-right"  end  

here is the ajax request i make from

leads.coffee

  update_new_leads = ->      $.ajax({        type    : 'GET',        url     : "admin/leads/fresh_leads',        success : function(data) {                    alert("success!");                  }      })  

error

ActionView::MissingTemplate (Missing template admin/leads/fresh_leads, admin/base/fresh_leads, application/fresh_leads with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :slim, :coffee, :jbuilder]}. Searched in:    * "/Users/me/Desktop/xyz/app/views"    * "/Users/me/.rvm/gems/jruby-9.1.2.0/gems/kaminari-0.17.0/app/views"    * "/Users/me/.rvm/gems/jruby-9.1.2.0/gems/devise-4.2.0/app/views"  ):    app/controllers/admin/leads_controller.rb:24:in `fresh_leads'    app/middleware/catch_json_parse_errors.rb:8:in `call'  

Convert .js.erb to js.haml

Posted: 01 Oct 2016 07:28 AM PDT

I have an ajax code that removes posts from the page:

$("#post_delete").on("ajax:success", function(data){    $("#<%= j @post.id.to_s %>").fadeOut();  });  

It works only in the erb format, but when I try to use the haml I recieve an error - "Illegal nesting"

$("#post_delete").on("ajax:success", function(data){    $("#" + "#{j @post.id.to_s}").fadeOut();  });  

devise hidden field for redirect

Posted: 01 Oct 2016 04:48 AM PDT

I have devise redirecting to previous page setup for my application using hidden_field_tag. Now I added the favorite action on my website and I'd like that user once click the favorite button can signup using a popover and that favorite get saved. I created the popover using a modal and it's working but once the user sign up - the favorite is obviously not created. I tried to pass an hidden field just for the modal like this

<%= hidden_field_tag("page_id", "favorite") %>  

then on application_controller I added

if params[:page_id] == "favorite"    favorite_item_path(@item, type: "favorite", method: :put)  end  

the items controller has the favorite action like this

def favorite  @item = Item.find(params[:id])     type = params[:type]  if type == "favorite"    current_user.favorites << @item    redirect_to :back    elsif type == "unfavorite"    current_user.favorites.delete(@item)    redirect_to :back    else    redirect_to :back, notice: 'Nothing happened.'  end  

end

here is the form on the modal

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>        <%= devise_error_messages! %>          <div class="field">          <%= f.text_field :username, autofocus: true, placeholder: "Create a username", class: "form-control" %>        </div>          <br>          <div class="field">          <%= f.email_field :email, placeholder: "Enter your email", class: "form-control" %>        </div>          <br>          <div class="field">          <%= f.password_field :password, autocomplete: "off", placeholder: "Choose your password", class: "form-control" %>        </div>          <br>          <div class="actions">          <%= hidden_field_tag("page_id", "favorite") %>          <%= f.submit "Sign up", class: "btn" %>        </div>          <% end %>  

and when I try to signup i get the following error

No route matches {:action=>"favorite", :controller=>"items", :id=>nil, :method=>:put, :type=>"favorite"} missing required keys: [:id]

How can I pass the id on the modal?

thanks

Why is rails server sending GET request and i put in a POST request for form_for?

Posted: 01 Oct 2016 05:14 AM PDT

//sessions controller

  def welcome      @user = User.new    end      def create      user = User.find_by_username(params[:username])      if user.authenticate(params[:password])        session[:user_id] = user.id        redirect_to root_path      else        redirect_to user_login_path      end    end  

//view this one doesn't work it sends a GET request

 <%= form_for @user, url: create_user_session_url do |f| %>      <div class="form_group">        <%= f.text_field :username, placeholder: "Username", class: "form-control" %>      </div>      <div class="form_group">        <%= f.password_field :password, placeholder: "Password", class: "form-control" %>      </div>      <div class="form-group">        <%= f.submit "Login", class: "form-control" %>      </div>    <% end %>  

//view one works and successfully sends POST request

  <%= form_for @user, url: create_user_registration_url do |f| %>      <div class="form_group">        <%= f.text_field :username, placeholder: "Username", class: "form-control" %>      </div>      <div class="form_group">        <%= f.email_field :email, placeholder: "Email", class: "form-control" %>      </div>      <div class="form_group">        <%= f.password_field :password, placeholder: "Password", class: "form-control" %>      </div>      <div class="form_group">        <%= password_field_tag "confirm_password", nil, placeholder: "Confirm Password", class: "form-control" %>      </div>      <div class="form-group">        <%= f.submit "Sign Up", class: "form-control" %>      </div>    <% end %>  

This is my form, when I do rake db:routes in console, create_user_session CLEARLY says its post.

                   Prefix Verb   URI Pattern             Controller#Action                       root GET    /                       application#index   create_user_registration POST   /user/login(.:format)   user/registrations#create  destroy_user_registration DELETE /user(.:format)         user/registrations#destroy          user_registration GET    /user(.:format)         user/registrations#show                            PATCH  /user(.:format)         user/registrations#update                            PUT    /user(.:format)         user/registrations#update           new_user_session GET    /user/welcome(.:format) user/sessions#welcome        create_user_session POST   /user/session(.:format) user/sessions#create       destroy_user_session DELETE /user/logout(.:format)  user/sessions#destroy  

HOWEVER, my stupid server thinks its sending a GET request, Started GET "/user/welcome" I'm really confused cause I have another form with the same syntax and it successfully sends a POST request. I don't even get any errors so it's so hard to debug.

Just incase I wasn't clear, my server does NOT even attempt to send a POST request.

How to display a video from youtube link saved in database in rails

Posted: 01 Oct 2016 07:02 AM PDT

I need some help. My project is to build an app to workout. I don't want to host any video, so in my form I just save youtube links in my database instead of the actual videos. I don't know how to display the video when it comes from the link in my database, though. Any idea ?! thanks !

   <div class="exercices">      <% for exercice in @workout.exercices %>      <div class="row">          <div class="col-md-4">              <video src="http://<%= exercice.link %>" ></video>          </div>          <div class="col-md-2"><%= exercice.number %></div>          <div class="col-md-6"><%= exercice.name %></div>      </div>     <% end %>  

How do I unsubscribe client from a server side

Posted: 01 Oct 2016 04:16 AM PDT

Let's say you have new subscriber:

class SomeChannel < ApplicationCable::Channel    def subscribed      stream_from "user_#{uuid}"    end  

You can easily reject him from your channel class.

def subscribed    stream_from "player_#{uuid}"    reject_subscription  end  

But what if I want to unsubscribe my cliend from, let's say, a controller?

Rails action cable specific consumer

Posted: 01 Oct 2016 04:08 AM PDT

I'm struggling with action cable. In my case I have couple of users (via Devise) who can share tasks with each other.

Now when user#1 share task (via Form) with user#2 all authenticated users receive notifications.

How and where should I identify my user#2 to broadcast only to him?

Here is my code so far:

connection.rb

module ApplicationCable    class Connection < ActionCable::Connection::Base      identified_by :current_user        def connect        self.current_user = find_verified_user        logger.add_tags 'ActionCable', current_user.id      end        protected        def find_verified_user # this checks whether a user is authenticated with devise        if verified_user = env['warden'].user          verified_user        else          reject_unauthorized_connection        end      end    end  end  

cable.js

(function() {    this.App || (this.App = {});      App.cable = ActionCable.createConsumer();    }).call(this);  

todo_channel.rb

class TodoChannel < ApplicationCable::Channel    def subscribed      stream_from "todo_channel_#{current_user.id}"    end      def unsubscribed      # Any cleanup needed when channel is unsubscribed    end        def notify      ActionCable.server.broadcast "todo_channel_#{current_user.id}", message: 'some message'(not implemented yet)    end  end  

todo.coffee

App.todo = App.cable.subscriptions.create "TodoChannel",    connected: ->      # Called when the subscription is ready for use on the server      disconnected: ->      # Called when the subscription has been terminated by the server      received: (data) ->      console.log(data['message'])      notify: ->      @perform 'notify'  

rails 5 - ActionController::UnknownFormat when sending data from angular

Posted: 01 Oct 2016 04:00 AM PDT

I started to study angular with rails. This is my problem, when I make a $http.get() request it returns and error, I think rails don't want to accept the data. this is my code:

View:

<div class="row">          <div class="col-md-12">            <div class="form-group">              <label for="signup_user_name">User name: </label>              <input type="text" name="instructor[user_name]" id="signup_user_name" class="form-control" required="true" ng-model="instructor.username"/>              <button type="button" class="form-control btn btn-default" ng-click="validate()">validate username</button>            </div>          </div>        </div>  

Controller:

signup.controller('signupController', function($scope, $http){        $scope.validate = function() {        var username = $scope.instructor.username        var sent_data = { "username" : username };        $http.get('/home/signup', sent_data).success(        function(data, status, headers, config) {          // write code later        }).error(        function(data, status, headers, config) {         // write code later        });      }  });  

rails method:

def signup     params[:username] // trying to print the paramater sent by angular via $http.get()   end  

This is the result:

Link to image result Please help me... thanks! :)

remove search string/ query attribute from where condition for multiple attribute search. remove blank attribute for blank params from where condition

Posted: 01 Oct 2016 04:31 AM PDT

I want to search products from Product table with multiple params but i want to only search for those params not blank. i am using this query for this.

@search_result = Product.where(:status_id=>1,:brand_id => @brand_id,   :product_name_id => @product_name_id, :size_id => @product_size_id,  :product_type_id => @product_type_id )  

i want like this if @product_name_id.blank? then the query should be like

@search_result = Product.where(:status_id=>1,:brand_id => @brand_id, :size_id => @product_size_id,  :product_type_id => @product_type_id )  

@product_name_id should be removed from the query. i also tried

@search_result = Product.find_by_sql [                                               "SELECT * FROM products WHERE status_id = ? AND brand_id > ? AND product_name_id > ? AND size_id > ? AND product_type_id > ? AND grade > ? ",                                               "#{1}",                                               "#{ unless @brand_id.blank?                                                     @brand_id                                                   end                                                  }",                                               "#{ unless @product_name_id.blank?                                                      @product_name_id                                                   end                                                  }",                                               "#{ unless @product_size_id.blank?                                                      @product_size_id                                                   end                                                  }",                                               "#{ unless @product_type_id.blank?                                                     @product_type_id                                                   end                                                  }",                                               "#{ unless @grade.blank?                                                     @grade                                                   end                                                  }"                                           ]  

But it's not give the my desired result i mean return wrong result.

Overriding the queued email

Posted: 01 Oct 2016 03:28 AM PDT

I want to send an email to a user based on when their association model was last update. Let's say that associated model is called Foo.

An email should be sent out x minutes before 30 minutes:

# This method would be a callback. Names used are for example only  def my_method    user = User.first    # Things happen here then updates the Foo's table    # then:    foo_is_active = user.foo.updated_at >  30.minutes.ago ? true : false      # Send email if foo is not active    if !foo_is_active     # sending email with deliver_later!(wait: 20 minutes)     # Email has a link to re-auth. Auth would do this same callback by calling my_method    end  end  

On first callback, an email will wait 20 minutes before sending. But what if the user re-auths within 30 minutes, I need another email to queue but overrides the first. Instead of the if statement, how to override the first queued email with last?

My code above, if user re-auths within 30 mins, would not queue an email but an email must be in queue when the table was last updated whilst only having one queue of email to be sent. How to go about this? Am I making sense?

Layman's term: Remind me to reauth before 30 minutes of each callback.

Application Error. Heroku deployment

Posted: 01 Oct 2016 05:34 AM PDT

Guys I followed the steps by uploading my website to Heroku but i can't open my website. Any idea? this is my logs.

I get this error

Application Error An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

2016-10-01T10:06:36.169967+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/server.rb:282:in `start'  2016-10-01T10:06:36.169968+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'  2016-10-01T10:06:36.169968+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/server.rb:79:in `start'  2016-10-01T10:06:36.169971+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'  2016-10-01T10:06:36.169971+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'  2016-10-01T10:06:36.169972+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'  2016-10-01T10:06:36.169974+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'  2016-10-01T10:06:36.169975+00:00 app[web.1]:    from bin/rails:4:in `require'  2016-10-01T10:06:36.169975+00:00 app[web.1]:    from bin/rails:4:in `<main>'  2016-10-01T10:06:36.275138+00:00 heroku[web.1]: State changed from starting to crashed  2016-10-01T10:06:36.266024+00:00 heroku[web.1]: Process exited with status 1  2016-10-01T10:07:43.959981+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-basin-19893.herokuapp.com request_id=fb12e47e-dc0d-4729-90db-f89  24f36cf6c fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:07:46.067395+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-basin-19893.herokuapp.com request_id=651ac812-85be-4b  da-8f59-6d8f3498ddc3 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:07:51.057066+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-basin-19893.herokuapp.com request_id=0f410cc8-9fdc-45f1-8b25-723  9ff81a061 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:07:51.841094+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-basin-19893.herokuapp.com request_id=e5b2aadd-7102-4b  93-b1e9-fed57ffeff6d fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:08:24.115723+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-basin-19893.herokuapp.com request_id=0dde22ce-9c0d-4ca4-bcc5-7aa  0b968d952 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:08:25.240382+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-basin-19893.herokuapp.com request_id=1fc43b60-4eb6-41  2d-9aec-d889b5f0d8b8 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:09:32.710032+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-basin-19893.herokuapp.com request_id=29d89e0a-bc13-4670-99c9-fbe  c2f02c106 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:09:33.810413+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-basin-19893.herokuapp.com request_id=3127fe25-4f81-4e  56-96eb-4cbb4f5470a5 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:14:53.103026+00:00 heroku[web.1]: State changed from crashed to starting  2016-10-01T10:14:56.111168+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 14306 -e production`  2016-10-01T10:14:59.498769+00:00 app[web.1]: => Booting Puma  2016-10-01T10:14:59.498833+00:00 app[web.1]: => Rails 5.0.0.1 application starting in production on http://0.0.0.0:14306  2016-10-01T10:14:59.498860+00:00 app[web.1]: => Run `rails server -h` for more startup options  2016-10-01T10:15:00.116483+00:00 app[web.1]: /app/app/controllers/visitor_permits_controller.rb:18: warning: else without rescue is useless  2016-10-01T10:15:00.800902+00:00 app[web.1]: Exiting  2016-10-01T10:15:00.801090+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': No such file to load -- t  est_helper (LoadError)  2016-10-01T10:15:00.801104+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'  2016-10-01T10:15:00.801117+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'  2016-10-01T10:15:00.801128+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'  2016-10-01T10:15:00.801140+00:00 app[web.1]:    from /app/app/models/user_test.rb:1:in `<top (required)>'  2016-10-01T10:15:00.801151+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'  2016-10-01T10:15:00.801163+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'  2016-10-01T10:15:00.801174+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'  2016-10-01T10:15:00.801186+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'  2016-10-01T10:15:00.801204+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:380:in `block in require_or_load'  2016-10-01T10:15:00.801216+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:37:in `block in load_interlock'  2016-10-01T10:15:00.801228+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading'  2016-10-01T10:15:00.801240+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/concurrency/share_lock.rb:117:in `exclusive'  2016-10-01T10:15:00.801256+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies/interlock.rb:11:in `loading'  2016-10-01T10:15:00.801268+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:37:in `load_interlock'  2016-10-01T10:15:00.801280+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:358:in `require_or_load'  2016-10-01T10:15:00.801291+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:336:in `depend_on'  2016-10-01T10:15:00.801306+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:252:in `require_dependency'  2016-10-01T10:15:00.801317+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'  2016-10-01T10:15:00.801329+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:475:in `each'  2016-10-01T10:15:00.801340+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:475:in `block in eager_load!'  2016-10-01T10:15:00.801352+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:473:in `each'  2016-10-01T10:15:00.801363+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:473:in `eager_load!'  2016-10-01T10:15:00.801374+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:354:in `eager_load!'  2016-10-01T10:15:00.801385+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:59:in `each'  2016-10-01T10:15:00.801396+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'  2016-10-01T10:15:00.801424+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `run'  2016-10-01T10:15:00.801411+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `instance_exec'  2016-10-01T10:15:00.801435+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'  2016-10-01T10:15:00.801446+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'  2016-10-01T10:15:00.801457+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'  2016-10-01T10:15:00.801468+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'  2016-10-01T10:15:00.801479+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'  2016-10-01T10:15:00.801490+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each'  2016-10-01T10:15:00.801501+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `call'  2016-10-01T10:15:00.801512+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'  2016-10-01T10:15:00.801523+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'  2016-10-01T10:15:00.801534+00:00 app[web.1]:    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'  2016-10-01T10:15:00.801545+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:in `run_initializers'  2016-10-01T10:15:00.801557+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:352:in `initialize!'  2016-10-01T10:15:00.801572+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'  2016-10-01T10:15:00.801589+00:00 app[web.1]:    from /app/config.ru:3:in `require_relative'  2016-10-01T10:15:00.801605+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'  2016-10-01T10:15:00.801617+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'  2016-10-01T10:15:00.801628+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'  2016-10-01T10:15:00.801653+00:00 app[web.1]:    from /app/config.ru:in `new'  2016-10-01T10:15:00.801752+00:00 app[web.1]:    from /app/config.ru:in `<main>'  2016-10-01T10:15:00.801765+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'  2016-10-01T10:15:00.801776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'  2016-10-01T10:15:00.801787+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'  2016-10-01T10:15:00.801798+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'  2016-10-01T10:15:00.801810+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'  2016-10-01T10:15:00.801821+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/server.rb:59:in `app'  2016-10-01T10:15:00.801832+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'  2016-10-01T10:15:00.801855+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/server.rb:79:in `start'  2016-10-01T10:15:00.801843+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/server.rb:282:in `start'  2016-10-01T10:15:00.801866+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'  2016-10-01T10:15:00.801877+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'  2016-10-01T10:15:00.801889+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'  2016-10-01T10:15:00.801900+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'  2016-10-01T10:15:00.801922+00:00 app[web.1]:    from bin/rails:4:in `require'  2016-10-01T10:15:00.801911+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'  2016-10-01T10:15:00.801934+00:00 app[web.1]:    from bin/rails:4:in `<main>'  2016-10-01T10:15:00.963075+00:00 heroku[web.1]: Process exited with status 1  2016-10-01T10:15:00.981253+00:00 heroku[web.1]: State changed from starting to crashed  2016-10-01T10:15:01.641973+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-basin-19893.herokuapp.com request_id=2e381d2e-dae6-48cd-a538-11b  e273e5e95 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:15:02.715647+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-basin-19893.herokuapp.com request_id=6f71493d-c680-4f  ce-8e86-ee343ce4d90a fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:15:40.496226+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by leechunvoo@gmail.com  2016-10-01T10:15:43.381875+00:00 heroku[run.2762]: Awaiting client  2016-10-01T10:15:43.428171+00:00 heroku[run.2762]: Starting process with command `bundle exec rake db:migrate`  2016-10-01T10:15:43.657102+00:00 heroku[run.2762]: State changed from starting to up  2016-10-01T10:15:48.751122+00:00 heroku[run.2762]: Process exited with status 0  2016-10-01T10:15:48.802610+00:00 heroku[run.2762]: State changed from up to complete  2016-10-01T10:15:55.874848+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-basin-19893.herokuapp.com request_id=2b897bed-3553-416e-904d-d06  ae92bcc8e fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  2016-10-01T10:15:58.077833+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-basin-19893.herokuapp.com request_id=47c29d1f-d4c6-46  78-a4db-cbde4c3fd961 fwd="60.242.10.208" dyno= connect= service= status=503 bytes=  

This is the logs i got from heroku run rails console

Running rails console on safe-basin-19893... up, run.2536 (Free)  /app/app/controllers/visitor_permits_controller.rb:18: warning: else without rescue is useless  /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': No such file to load -- test_helper (LoadError)          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'          from /app/app/models/user_test.rb:1:in `<top (required)>'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:380:in `block in require_or_load'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:37:in `block in load_interlock'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/concurrency/share_lock.rb:117:in `exclusive'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies/interlock.rb:11:in `loading'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:37:in `load_interlock'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:358:in `require_or_load'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:336:in `depend_on'          from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:252:in `require_dependency'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:475:in `each'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:475:in `block in eager_load!'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:473:in `each'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:473:in `eager_load!'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:354:in `eager_load!'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:59:in `each'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `instance_exec'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `run'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `call'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'          from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:in `run_initializers'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:352:in `initialize!'          from /app/config/environment.rb:5:in `<top (required)>'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:328:in `require'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:328:in `require_environment!'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:157:in `require_application_and_environment!'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:77:in `console'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'          from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'          from /app/bin/rails:4:in `require'          from /app/bin/rails:4:in `<main>'  

Visitor Permit controller

class VisitorPermitsController < ApplicationController      before_action :set_vpermit, only: [:show, :destroy]      def index        @vpermit = VisitorPermit.all      end        def new        @vpermit = VisitorPermit.new      end        def create          @vpermit = VisitorPermit.new(vpermit_params)          if @vpermit.save            redirect_to @vpermit          end        else          end          def destroy        VisitorPermit.destroy_all(user_id: current_user)        respond_to do |format|          format.html { redirect_to root_path, notice: 'Permit was successfully canceled.' }          format.json { head :no_content }        end      end        def show        @vpermit = VisitorPermit.find(params[:id])      end        def update        @vpermit = VisitorPermit.where(user_id: current_user).take        respond_to do |format|          if @vpermit.update(vpermit_params)            format.html { redirect_to root_path}            flash[:success] = "Permit successfully updated"            format.json { render :show, status: :ok, location: @vpermit }          else            format.html { render :edit }            format.json { render json: @vpermit.errors, status: :unprocessable_entity }          end        end      end        private      # Use callbacks to share common setup or constraints between actions.      def set_vpermit        @vpermit = VisitorPermit.find(params[:id])      end        # Never trust parameters from the scary internet, only allow the white list through.      def vpermit_params        params.require(:visitor_permit).permit(:vehicle_type, :name, :department, :carplate, :duration, :permitstart, :permitend)      end    end  

param is missing or the value is empty: ph - rails

Posted: 01 Oct 2016 03:28 AM PDT

This is a possible duplicate, but I have read and tried nearly all suggestions, but I keep getting the error on the New action view. I am using Rails 5.

I have tried the following:

private     def ph_params        params.require(:ph).permit(:amount)     end  

And also tried the following, and the error disappeared, but my values were not saving to database, only shows Nil:

private     def ph_params        params.permit(:amount)     end  

My controller:

class PhsController < ApplicationController     def index     end       def new       @ph = Ph.new(ph_params)     end       def create       @ph = Ph.new(ph_params)        respond_to do |format|        if @ph.save          format.html {   redirect_to @ph }       else          format.html { render "new" }       end       end    end       def show       @ph = Ph.find(params[:id])     end    private    def ph_params      params.require(:ph).permit(:amount)    end  end  

new.html.erb form start

<%= simple_form_for @ph, url: phs_path do |f| %>  

Model

class Ph < ApplicationRecord    end  

I might be missing something. Your assistance is appreciated, thank you in advance.

rails 4 Test case :NoMethodError: undefined method `create' for ArticleTest:Class

Posted: 01 Oct 2016 03:02 AM PDT

I am begginer in rails "test" cases. for practice purpose i have writtin one test case where i am checking if saved object is valid or not. after running this test case i am getting error as NoMethodError: undefined method create for ArticleTest:Class . i am following rails guide http://guides.rubyonrails.org/testing.html

require 'test_helper'    class ArticleTest < ActiveSupport::TestCase     test "the truth" do       @article = ArticleTest.create       assert @article.valid?     end  end  

what is wrong in my code ?

How to create dynamic dropdowns in rails with ONE model?

Posted: 01 Oct 2016 02:50 AM PDT

If been looking for a solution for this problem now for quite some time, however I can only find very complicated solutions involving jquery or multiple models with associations that I cant quite figure out.

I have a product class that has instance variables such as country and cities. Meaning in my database, each product row has a country and a city stored. Now I would like to create two dropdowns in my view where I can select a country in the first drop down and the corresponding cities in the second drop down.

My select tags look like this

<%= select_tag  :country, options_for_select(@country.sort_by(&:downcase), params[:country]), :include_blank => true %>  <%= select_tag  :city, options_for_select(@city.sort_by(&:downcase), params[:city]), :include_blank => true %>  

Can you help me with a solution for such a problem or maybe point me in the right direction?

Thank you very much!

An error occurred while installing nio4r (1.2.1), and Bundler cannot continue

Posted: 01 Oct 2016 12:36 AM PDT

Hi I'm working on putting my website to digital ocean. But when in the process when i Bundle install i get this error

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.        /usr/local/rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20161001-6508-ukh5t9.rb extconf.rb --with-cflags=-std=c99  checking for unistd.h... *** extconf.rb failed ***  Could not create Makefile due to some reason, probably lack of necessary  libraries and/or headers.  Check the mkmf.log file for more details.  You may  need configuration options.    Provided configuration options:          --with-opt-dir          --without-opt-dir          --with-opt-include          --without-opt-include=${opt-dir}/include          --with-opt-lib          --without-opt-lib=${opt-dir}/lib          --with-make-prog          --without-make-prog          --srcdir=.          --curdir          --ruby=/usr/local/rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)  /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)  You have to install development tools first.          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:587:in `try_cpp'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:1060:in `block in have_header'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:321:in `open'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:321:in `open'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'          from /usr/local/rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:1059:in `have_header'          from extconf.rb:3:in `<main>'    extconf failed, exit code 1    Gem files will remain installed in /usr/local/rvm/gems/ruby-2.2.4/gems/nio4r-1.2.1 for inspection.  Results logged to /usr/local/rvm/gems/ruby-2.2.4/extensions/x86_64-linux/2.2.0/nio4r-1.2.1/gem_make.out    An error occurred while installing nio4r (1.2.1), and Bundler cannot continue.  Make sure that `gem install nio4r -v '1.2.1'` succeeds before bundling.  

I'm using Putty.exe to configure it following the tutorial https://www.digitalocean.com/community/tutorials/how-to-use-the-ruby-on-rails-one-click-application-on-digitalocean

I'm using Ruby ruby 2.2.4p230 Rails 5.0.0.1

Not sure if this help. When i using Putty.exe to configure my website the tutorial said If your Gemfile specifies a version of Ruby that is different from the one installed on the system, you may install it using RVM. So I tried:

rvm install 2.2.4  rvm use ruby-2.2.4-p230 --default  

But I get the error ruby-2.2.4-p230 is not installed. And it can't installed because the system cannot find the specific version. So I use

 rvm use ruby-2.2.4  

How to show jquery content in PDF generated by using PDFKIT in Rails

Posted: 01 Oct 2016 12:23 AM PDT

I am using PDFKIT tool to generate PDF from HTML in Rails, it works fine, and generates pdf successfully, but there is a small problem,
that it doesn't show the content which is generating by jquery, for example, there is a range slider on the page, which is excluded in the pdf generated,

here is the link of the url i am trying to convert html to pdf

http://ourdesignzdev.info:3001/employee/resume/download?id=22

and here is the output:

enter image description here

Please compare the Skills section, it doesn't show the slider,

please if you have any idea why is this happening then please help me to sort this out.

Thanks.

How to send a message to every single connection

Posted: 01 Oct 2016 03:24 AM PDT

I know that in ActionCable the ping works this way:

def beat    transmit type: ActionCable::INTERNAL[:message_types][:ping], message: Time.now.to_i  end  

But when I try to transmit on connect, only one connecton gets my message with transmit why?

def connect    self.uuid = SecureRandom.uuid    transmit({'title': 'players_online', 'message': 'A new user has been subscribed'})  end  

Get all points that lies within a polygon on Google Map

Posted: 01 Oct 2016 12:02 AM PDT

I am building a Rails Application in which Google map is used for filtering all points on map with drawing tools
File Model.rb

class Model < ActiveRecord::Base    geocoded_by :address, :latitude  => :lat, :longitude => :lng      def address     [city, state].compact.join(', ')    end  end  

controller.rb

def in_bounds   unless params[:polygon].nil?     poly = params[:polygon].split('),(').map{|k| k = k.gsub(/[()]/, "")}     all_points = []     poly.each do |p|      all_points.push (p.split(',').collect(&:strip).map{ |k| k = k.to_f})     end         render json: all_points     return   end  end  


Output

[ [ 44.24519901522129, -77.36572265625 ], [ 42.84375132629021, -69.27978515625 ], [ 34.488447837809304, -67.87353515625 ], [ 36.06686213257888, -81.76025390625 ], [ 42.58544425738491, -81.93603515625 ] ]

How to find all points that lies within these specific co-ordinates
I am using this gem

No comments:

Post a Comment