Saturday, September 3, 2016

Rails 5 ActionController::RoutingError No route matches [POST] "/auth/sign_up" | Fixed issues

Rails 5 ActionController::RoutingError No route matches [POST] "/auth/sign_up" | Fixed issues


Rails 5 ActionController::RoutingError No route matches [POST] "/auth/sign_up"

Posted: 03 Sep 2016 07:37 AM PDT

GET and POST on /auth/sign_up is not functioning as expected. Getting the following 404 error

{      "status": 404,      "error": "Not Found",      "exception": "#<AbstractController::ActionNotFound: The action 'new' could not be found for DeviseTokenAuth::RegistrationsController>",      "traces": #too long to post; 46 traces; none includes user created files  }  

almost the same response for post

{      "status": 404,      "error": "Not Found",      "exception": "#<ActionController::RoutingError: No route matches [POST] \"/auth/sign_up\">",      "traces": #too long to post; 46 traces; none includes user created files  }  

Here's everything I did

  • Created a new Rails API project

    rails new untitled --javascript=jquery --api  
  • Added this to Gemfile

    #authentication  gem 'devise'  gem 'omniauth'  gem 'devise_token_auth'  
  • Ran the following

    bundle install  rails generate devise_token_auth:install User auth   rails db:migrate  rails s  
  • Tested the url localhost:3000/auth/sign_up GET from browser and GET and POST from Postman

My routes.rb

Rails.application.routes.draw do    mount_devise_token_auth_for 'User', at: 'auth'  end  

My rails routes output

              Prefix Verb     URI Pattern                            Controller#Action          new_user_session GET      /auth/sign_in(.:format)                devise_token_auth/sessions#new              user_session POST     /auth/sign_in(.:format)                devise_token_auth/sessions#create      destroy_user_session DELETE   /auth/sign_out(.:format)               devise_token_auth/sessions#destroy             user_password POST     /auth/password(.:format)               devise_token_auth/passwords#create         new_user_password GET      /auth/password/new(.:format)           devise_token_auth/passwords#new        edit_user_password GET      /auth/password/edit(.:format)          devise_token_auth/passwords#edit                           PATCH    /auth/password(.:format)               devise_token_auth/passwords#update                           PUT      /auth/password(.:format)               devise_token_auth/passwords#update  cancel_user_registration GET      /auth/cancel(.:format)                 devise_token_auth/registrations#cancel         user_registration POST     /auth(.:format)                        devise_token_auth/registrations#create     new_user_registration GET      /auth/sign_up(.:format)                devise_token_auth/registrations#new    edit_user_registration GET      /auth/edit(.:format)                   devise_token_auth/registrations#edit                           PATCH    /auth(.:format)                        devise_token_auth/registrations#update                           PUT      /auth(.:format)                        devise_token_auth/registrations#update                           DELETE   /auth(.:format)                        devise_token_auth/registrations#destroy         user_confirmation POST     /auth/confirmation(.:format)           devise_token_auth/confirmations#create     new_user_confirmation GET      /auth/confirmation/new(.:format)       devise_token_auth/confirmations#new                           GET      /auth/confirmation(.:format)           devise_token_auth/confirmations#show       auth_validate_token GET      /auth/validate_token(.:format)         devise_token_auth/token_validations#validate_token              auth_failure GET      /auth/failure(.:format)                devise_token_auth/omniauth_callbacks#omniauth_failure                           GET      /auth/:provider/callback(.:format)     devise_token_auth/omniauth_callbacks#omniauth_success                           GET|POST /omniauth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#redirect_callbacks          omniauth_failure GET|POST /omniauth/failure(.:format)            devise_token_auth/omniauth_callbacks#omniauth_failure                           GET      /auth/:provider(.:format)              redirect(301)  

Other things I've noticed

  • Other routes, for eg. /auth/sign_in works and I'm able to sign in successfully for the users I've created using Rails Console
  • Looks like a similar error caused this post, but not caused due to subdomain constraints in routes.rb Some have mentioned in the comments even after doing like what's given in the answer did not get rid of 404
  • Tried rails generate devise:controller User and uncommmented new section in RegistrationsController and added some random render :jsons which always throws up an empty JSON with status 200 with weird bin/rails: No such file or directory error on terminal which I couldn't get rid of using rails app:update:bin

What am I doing wrong?

rufus + puma + heroku warning

Posted: 03 Sep 2016 07:28 AM PDT

I'm running a rails app on heroku, I have two web dynos. How can I remove the ! WARNING: Detected 1 Thread(s) started in app boot: warning?

My puma.rb file:

workers Integer(ENV['WEB_CONCURRENCY'] || 2)  threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)  threads threads_count, threads_count    preload_app!    rackup      DefaultRackup  port        ENV['PORT']     || 3000  environment ENV['RACK_ENV'] || 'development'    on_worker_boot do |worker_number|     # Worker specific setup for Rails 4.1+    # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot    ActiveRecord::Base.establish_connection  end  

The logs:

2016-09-03T14:21:24.742960+00:00 app[web.1]: [3] * Listening on tcp://0.0.0.0:53786  2016-09-03T14:21:24.743135+00:00 app[web.1]: [3] ! WARNING: Detected 1 Thread(s) started in app boot:  2016-09-03T14:21:24.743181+00:00 app[web.1]: [3] ! #<Thread:0x007f382b59fca8@/app/vendor/bundle/ruby/2.2.0/gems/rufus-scheduler-3.2.2/lib/rufus/scheduler.rb:563 sleep> - /app/vendor/bundle/ruby/2.2.0/gems/rufus-scheduler-3.2.2/lib/rufus/scheduler.rb:571:in `sleep'  2016-09-03T14:21:24.743257+00:00 app[web.1]: [3] Use Ctrl-C to stop  2016-09-03T14:21:24.754941+00:00 app[web.1]: [3] - Worker 0 (pid: 7) booted, phase: 0  2016-09-03T14:21:24.756269+00:00 app[web.1]: [3] - Worker 1 (pid: 20) booted, phase: 0  2016-09-03T14:21:25.525174+00:00 app[web.2]: ** [NewRelic][2016-09-03 14:21:25 +0000 web.2 (18)] INFO : Doing deferred dependency-detection before Rack startup  

Adding semantic markup to a rails application / RDFa

Posted: 03 Sep 2016 07:00 AM PDT

I am surprised to see little information about this. I'd like to enhance my Rails webpages with semantic markup for use with Facebook/LinkedIn/Twitter and Search Engines.

Most things I find when typing "RDFA ruby/rails" are actually processors that can read/parse graphs and schemas, but not actually assist including semantic markup in a website.

I am wondering how people actually do this ? By passing RDFa in html_options in content_tag ? By manually adding this in the HTML views ?

I actually found this gem that seems to do that, but it's not on github, and the page seems to date from the pre-bootstrap era where people wrote raw html (if I may). There is no indication of activity on this gem, no single date on that page, and the download seems to be broken.

Is it something so uncommon for Rails websites to have semantic markup ??

undefined method for ActiveRecord_Associations_CollectionProxy [rails]

Posted: 03 Sep 2016 06:58 AM PDT

i'm building an invoice application and in the _form partial i made the invoice where users can add products including quantity, description and unitprice. And users can add extra rows to add more items(products).

Now when i try to display that information in the show view like this:

    <tbody>       <tr class="products_tr">        <td> <%= @invoice.products.quantity %> </td>        <td> <%= @invoice.products.description %> </td>        <td> <%= @invoice.products.unitprice %> </td>        <td class="row_total"><%= @invoice.products.quantity * @invoice.products.unitprice %></td>        <td> <%= @invoice.products.btw %> </td>       </tr>      </tbody>  

it gives out the next error:

undefined method `quantity' for #<Product::ActiveRecord_Associations_CollectionProxy:0x007fbe92831500>  

This is the code in the controller;

  def show      @invoice.products.build      @invoice.build_customer    end  

Any idea on how to fix this? help would be much appreciated. And plus points for an explanation on what it is exactly that i'm doing wrong.

EDIT

If i loop through the @invoice.products like Michał Młoźniak said it works but it also shows an extra row that contains nil, like this: enter image description here

Failing validation when trying to create a list with Rspec and FactoryGirl?

Posted: 03 Sep 2016 06:30 AM PDT

I have a test that is failing due to a

Secret#last_five returns the last 5 secrets when last_five is called   Failure/Error: let!(:secrets){create_list(:secret, 5)}     ActiveRecord::RecordInvalid:     Validation failed: Email has already been taken  

error and I am unsure how to fix it.

Here is the test in secret_spec.rb:

describe Secret do    describe "#last_five" do      let!(:secrets){create_list(:secret, 5)}      it "returns the last 5 secrets when last_five is called" do        expect(Secret.last_five.count).to eq(5)      end    end  end  

Here is the secret_factory.rb:

FactoryGirl.define do     factory :secret do       title "Title"      body "this is the body"      author    end    end  

Here is the user_factory.rb:

FactoryGirl.define do     factory :user, aliases: [:author] do       name "Foobar"      email Faker::Internet.safe_email      password "password"      password_confirmation "password"    end  end  

I am generating a random email address, and the user factory is the only place I'm using an Email, so I am confused as how I'm getting the Email already taken error.

Thanks for the help.

Rails server won't start due to "uninitialized constant Devise::Mailer"

Posted: 03 Sep 2016 05:58 AM PDT

Few other solutions were suggested in several other posts and I did follow them like, requiring devise inside the application.rb file. I have also reinstalled the devise gem along with its dependencies. After trying for several hours, I can't figure out a solution and the stack trace keeps on showing me that Devise::Mailer is an uninitialized constant with a Nameerror exception.

I've also installed the devise invitable gem but it didn't solve the problem. This actually started when I installed the gem facets and I'm using rails 5 Below you can have a look at the stack trace:

 usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:263:in `const_get': uninitialized constant Devise::Mailer (NameError)          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:263:in `block in constantize'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:259:in `each'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:259:in `inject'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:259:in `constantize'          from /usr/local/rvm/gems/ruby-2.3.0/gems/devise-4.2.0/lib/devise.rb:301:in `get'          from /usr/local/rvm/gems/ruby-2.3.0/gems/devise-4.2.0/lib/devise.rb:320:in `mailer'          from /usr/local/rvm/gems/ruby-2.3.0/gems/devise_invitable-1.7.0/lib/devise_invitable/rails.rb:12:in `block in <class:Engine>'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:in `instance_exec'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:in `block in make_lambda'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:192:in `block in simple'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `block in call'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `each'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `call'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:92:in `__run_callbacks__'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:778:in `_run_prepare_callbacks'          from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:81:in `run_callbacks'          from /usr/local/rvm/gems/ruby-2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/reloader.rb:83:in `prepare!'          from /usr/local/rvm/gems/ruby-2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/reloader.rb:55:in `prepare!'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:50:in `block in <module:Finisher>'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `call'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'          from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'          from /home/ubuntu/workspace/config/environment.rb:5:in `<top (required)>'          from /home/ubuntu/workspace/config.ru:3:in `block in <main>'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'          from /home/ubuntu/workspace/config.ru:in `new'          from /home/ubuntu/workspace/config.ru:in `<main>'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app'          from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'          from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'          from /home/ubuntu/workspace/bin/rails:9:in `require'          from /home/ubuntu/workspace/bin/rails:9:in `<top (required)>'          from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'          from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'          from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'          from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'          from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'          from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'          from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'          from /home/ubuntu/workspace/bin/spring:13:in `require'          from /home/ubuntu/workspace/bin/spring:13:in `<top (required)>'          from bin/rails:3:in `load'          from bin/rails:3:in `<main>'  

Paper trail with bigint on postgres + rails

Posted: 03 Sep 2016 05:16 AM PDT

I'd love to change serial int to serial big int. I use Postgresql 9.3.

Is there better way to do so other than rewriting the migration file paper_trails automatically generated? (I've checked out github page but couldn't find the right answer.)

Something like,

# This migration creates the `versions` table, the only schema PT requires.  # All other migrations PT provides are optional.  class CreateVersions < ActiveRecord::Migration    # Class names of MySQL adapters.    # - `MysqlAdapter` - Used by gems: `mysql`, `activerecord-jdbcmysql-adapter`.    # - `Mysql2Adapter` - Used by `mysql2` gem.    MYSQL_ADAPTERS = [      "ActiveRecord::ConnectionAdapters::MysqlAdapter",      "ActiveRecord::ConnectionAdapters::Mysql2Adapter"    ].freeze      # Class names of PostgreSQL adapters.    POSTGRESQL_ADAPTERS = [      "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter",    ].freeze      # The largest text column available in all supported RDBMS is    # 1024^3 - 1 bytes, roughly one gibibyte.  We specify a size    # so that MySQL will use `longtext` instead of `text`.  Otherwise,    # when serializing very large objects, `text` might not be big enough.    TEXT_BYTES = 1_073_741_823      def change      create_table :versions, versions_table_options do |t|        t.string   :item_type, item_type_options        t.integer  :item_id,   null: false, limit: 8        t.string   :event,     null: false        t.string   :whodunnit        t.text     :object, limit: TEXT_BYTES          # Known issue in MySQL: fractional second precision        # -------------------------------------------------        #        # MySQL timestamp columns do not support fractional seconds unless        # defined with "fractional seconds precision". MySQL users should manually        # add fractional seconds precision to this migration, specifically, to        # the `created_at` column.        # (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)        #        # MySQL users should also upgrade to rails 4.2, which is the first        # version of ActiveRecord with support for fractional seconds in MySQL.        # (https://github.com/rails/rails/pull/14359)        #        t.datetime :created_at      end      add_index :versions, [:item_type, :item_id]    end      private      # MySQL 5.6 utf8mb4 limit is 191 chars for keys used in indexes.    # See https://github.com/airblade/paper_trail/issues/651    def item_type_options      opt = { null: false }      opt[:limit] = 191 if mysql?      opt    end      def mysql?      MYSQL_ADAPTERS.include?(connection.class.name)    end      def postgres?      POSTGRESQL_ADAPTERS.include?(connection.class.name)    end      # Even modern versions of MySQL still use `latin1` as the default character    # encoding. Many users are not aware of this, and run into trouble when they    # try to use PaperTrail in apps that otherwise tend to use UTF-8. Postgres, by    # comparison, uses UTF-8 except in the unusual case where the OS is configured    # with a custom locale.    #    # - https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html    # - http://www.postgresql.org/docs/9.4/static/multibyte.html    #    # Furthermore, MySQL's original implementation of UTF-8 was flawed, and had    # to be fixed later by introducing a new charset, `utf8mb4`.    #    # - https://mathiasbynens.be/notes/mysql-utf8mb4    # - https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html    #    def versions_table_options      if mysql?        { options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }      elsif postgres?        { id: :bigserial }      end    end  end  

Or maybe should I change the column type later with ALTER?

NoMethodError: undefined method `web_console' for #<Rails::Application::Configuration while deploying to Heroku

Posted: 03 Sep 2016 05:36 AM PDT

Any ideas how to fix it? Website is working fine locally.

My error is: NoMethodError: undefined method 'web_console' for #<Rails::Application::Configuration

I tried to google for solution, but I didn't find right answer. I'm getting this error while deployiong to Heroku.

Counting objects: 134, done.  Delta compression using up to 4 threads.  Compressing objects: 100% (131/131), done.  Writing objects: 100% (134/134), 151.11 KiB | 0 bytes/s, done.  Total 134 (delta 72), reused 0 (delta 0)  remote: Compressing source files... done.  remote: Building source:  remote:   remote: -----> Ruby app detected  remote: -----> Compiling Ruby/Rails  remote: -----> Using Ruby version: ruby-2.2.4  remote: -----> Installing dependencies using bundler 1.11.2  remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment  remote:        Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.  remote:        Fetching gem metadata from https://rubygems.org/...........  remote:        Fetching version metadata from https://rubygems.org/...  remote:        Fetching dependency metadata from https://rubygems.org/..  remote:        Using rake 11.2.2  remote:        Using i18n 0.7.0  remote:        Using json 1.8.3  remote:        Using minitest 5.9.0  remote:        Using thread_safe 0.3.5  remote:        Using builder 3.2.2  remote:        Using erubis 2.7.0  remote:        Using mini_portile2 2.1.0  remote:        Using pkg-config 1.1.7  remote:        Using rack 1.6.4  remote:        Using mime-types-data 3.2016.0521  remote:        Using arel 6.0.3  remote:        Using acts_as_votable 0.10.0  remote:        Using execjs 2.7.0  remote:        Using bcrypt 3.1.11  remote:        Using sass 3.4.22  remote:        Using cancancan 1.15.0  remote:        Using coffee-script-source 1.10.0  remote:        Using thor 0.19.1  remote:        Using bundler 1.11.2  remote:        Using concurrent-ruby 1.0.2  remote:        Using orm_adapter 0.5.0  remote:        Using devise-i18n 1.1.0  remote:        Using tilt 2.0.5  remote:        Using sexp_processor 4.7.0  remote:        Using multi_json 1.12.1  remote:        Using mimemagic 0.3.1  remote:        Using nested_form 0.3.2  remote:        Using pg 0.18.4  remote:        Installing decent_exposure 2.3.3  remote:        Installing puma 3.6.0 with native extensions  remote:        Installing request_store 1.3.1  remote:        Using rails_serve_static_assets 0.0.5  remote:        Using rails_stdout_logging 0.0.5  remote:        Using remotipart 1.2.1  remote:        Using safe_yaml 1.0.4  remote:        Using will_paginate 3.1.0  remote:        Using rdoc 4.2.2  remote:        Using tzinfo 1.2.2  remote:        Using mime-types 3.1  remote:        Using nokogiri 1.6.8  remote:        Using rack-test 0.6.3  remote:        Using warden 1.2.6  remote:        Using autoprefixer-rails 6.3.6.1  remote:        Using uglifier 3.0.0  remote:        Using coffee-script 2.4.1  remote:        Using sprockets 3.6.0  remote:        Using haml 4.0.7  remote:        Using ruby_parser 3.8.2  remote:        Installing decent_decoration 0.0.6  remote:        Using rails_12factor 0.0.3  remote:        Using will_paginate-bootstrap 1.0.1  remote:        Using sdoc 0.4.1  remote:        Using activesupport 4.2.6  remote:        Using mail 2.6.4  remote:        Installing faker 1.6.6  remote:        Using loofah 2.0.3  remote:        Using rack-pjax 0.8.0  remote:        Using bootstrap-sass 3.3.6  remote:        Using html2haml 2.0.0  remote:        Using rails-deprecated_sanitizer 1.0.3  remote:        Using globalid 0.3.6  remote:        Using activemodel 4.2.6  remote:        Using climate_control 0.0.3  remote:        Using jbuilder 2.5.0  remote:        Using rails-html-sanitizer 1.0.3  remote:        Using rails-dom-testing 1.0.7  remote:        Using activejob 4.2.6  remote:        Using activerecord 4.2.6  remote:        Using cocaine 0.5.8  remote:        Using actionview 4.2.6  remote:        Using paperclip 5.0.0  remote:        Using actionpack 4.2.6  remote:        Using actionmailer 4.2.6  remote:        Using active_link_to 1.0.3  remote:        Using railties 4.2.6  remote:        Using sprockets-rails 3.0.4  remote:        Using kaminari 0.17.0  remote:        Using simple_form 3.2.1  remote:        Using coffee-rails 4.1.1  remote:        Using jquery-rails 4.1.1  remote:        Using responders 2.2.0  remote:        Using font-awesome-rails 4.6.3.1  remote:        Using haml-rails 0.9.0  remote:        Using jquery-ui-rails 5.0.5  remote:        Using rails 4.2.6  remote:        Using sass-rails 5.0.4  remote:        Using turbolinks 2.5.3  remote:        Using devise 4.1.1  remote:        Using commontator 4.11.1  remote:        Using rails_admin 0.8.1  remote:        Using jquery-turbolinks 2.1.0  remote:        Installing draper 2.1.0  remote:        Bundle complete! 43 Gemfile dependencies, 93 gems now installed.  remote:        Gems in the groups development and test were not installed.  remote:        Bundled gems are installed into ./vendor/bundle.  remote:        Bundle completed (6.43s)  remote:        Cleaning up the bundler cache.  remote:        Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.  remote: sh: 2: Syntax error: Unterminated quoted string  remote: sh: 2: Syntax error: Unterminated quoted string  remote:  !  remote:  !     Could not detect rake tasks  remote:  !     ensure you can run `$ bundle exec rake -P` against your app  remote:  !     and using the production group of your Gemfile.  remote:  !     rake aborted!  remote:  !     NoMethodError: undefined method `web_console' for #<Rails::Application::Configuration:0x007f04617e1b40>  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/railtie/configuration.rb:95:in `method_missing'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/config/application.rb:25:in `<class:Application>'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/config/application.rb:10:in `<module:Angipl>'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/config/application.rb:9:in `<top (required)>'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/Rakefile:4:in `require'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/Rakefile:4:in `<top (required)>'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load_rakefile'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:686:in `raw_load_rakefile'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:96:in `block in load_rakefile'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:95:in `load_rakefile'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:79:in `block in run'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'  remote:  !     /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'  remote:  !     vendor/bundle/bin/rake:16:in `load'  remote:  !     vendor/bundle/bin/rake:16:in `<main>'  remote:  !  remote: /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/helpers/rake_runner.rb:102:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)  remote: ensure you can run `$ bundle exec rake -P` against your app  remote: and using the production group of your Gemfile.  remote: rake aborted!  remote: NoMethodError: undefined method `web_console' for #<Rails::Application::Configuration:0x007f04617e1b40>  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/railtie/configuration.rb:95:in `method_missing'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/config/application.rb:25:in `<class:Application>'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/config/application.rb:10:in `<module:Angipl>'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/config/application.rb:9:in `<top (required)>'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/Rakefile:4:in `require'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/Rakefile:4:in `<top (required)>'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load_rakefile'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:686:in `raw_load_rakefile'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:96:in `block in load_rakefile'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:95:in `load_rakefile'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:79:in `block in run'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'  remote: /tmp/build_a0a3715eb7863d440ca59f388461f927/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'  remote: vendor/bundle/bin/rake:16:in `load'  remote: vendor/bundle/bin/rake:16:in `<main>'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/ruby.rb:746:in `rake'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails4.rb:77:in `block (2 levels) in run_assets_precompile_rake_task'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:131:in `log'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails4.rb:71:in `block in run_assets_precompile_rake_task'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:17:in `block in instrument'  remote:     from /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:16:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:48:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:44:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails4.rb:70:in `run_assets_precompile_rake_task'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/ruby.rb:104:in `block (2 levels) in compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/ruby.rb:767:in `allow_git'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/ruby.rb:98:in `block in compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:17:in `block in instrument'  remote:     from /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:16:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:48:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:44:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/ruby.rb:88:in `compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails2.rb:49:in `block in compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:17:in `block in instrument'  remote:     from /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:16:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:48:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:44:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails2.rb:47:in `compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails3.rb:38:in `block in compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:17:in `block in instrument'  remote:     from /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:16:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:48:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:44:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails3.rb:37:in `compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails4.rb:41:in `block in compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:17:in `block in instrument'  remote:     from /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:16:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:48:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:44:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/rails4.rb:40:in `compile'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/bin/compile:16:in `block (2 levels) in <main>'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/base.rb:131:in `log'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/bin/compile:15:in `block in <main>'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:35:in `block in trace'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:17:in `block in instrument'  remote:     from /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:16:in `instrument'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:35:in `trace'  remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/bin/compile:11:in `<main>'  remote:  !     Push rejected, failed to compile Ruby app.  remote:   remote:  !     Push failed  remote: Verifying deploy...  remote:   remote: !   Push rejected to angipl.  remote:   To https://git.heroku.com/angipl.git   ! [remote rejected] master -> master (pre-receive hook declined)  error: failed to push some refs to 'https://git.heroku.com/angipl.git'  

My gemfile looks like that:

source 'https://rubygems.org'      # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'  gem 'rails', '4.2.6'  # Use sqlite3 as the database for Active Record  group :development, :test do    gem 'sqlite3'  end  group :production do    gem 'pg', '~> 0.18.4'  end  # Use Uglifier as compressor for JavaScript assets  gem 'uglifier', '>= 1.3.0'  # Use CoffeeScript for .coffee assets and views  gem 'coffee-rails', '~> 4.1.0'  # See https://github.com/rails/execjs#readme for more supported runtimes  # gem 'therubyracer', platforms: :ruby    # Use jquery as the JavaScript library  gem 'jquery-rails'  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks  gem 'turbolinks'  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder  gem 'jbuilder', '~> 2.0'  # bundle exec rake doc:rails generates the API under doc/api.  gem 'sdoc', '~> 0.4.0', group: :doc    # Use ActiveModel has_secure_password  # gem 'bcrypt', '~> 3.1.7'    # Use Unicorn as the app server  # gem 'unicorn'    # Use Capistrano for deployment  # gem 'capistrano-rails', group: :development      gem 'haml', '~> 4.0.5'  gem "haml-rails", "~> 0.9"  gem 'bootstrap-sass', '~> 3.3.6'  gem 'sass-rails', '>= 3.2'  gem 'devise'  gem 'simple_form'  gem 'jquery-turbolinks'  gem 'active_link_to'  gem 'commontator', '~> 4.11.1'  gem 'devise-i18n'  gem 'acts_as_votable', '~> 0.10.0'  gem 'will_paginate', '~> 3.1.0'  gem 'will_paginate-bootstrap'  gem 'rails_admin'  gem 'cancancan', '~> 1.10'  gem "paperclip", "~> 5.0.0"  gem 'draper', '~> 2.1'  gem 'decent_exposure', '~> 2.3', '>= 2.3.3'  gem 'decent_decoration', '~> 0.0.6'  gem 'faker', '~> 1.6', '>= 1.6.3'    group :development, :test do    gem 'rspec-rails', '~> 3.4'    gem 'byebug'    gem 'factory_girl_rails'    gem 'spring'    gem 'web-console', '~> 2.0'    gem "better_errors"    gem 'capybara'  end    group :production do    gem 'puma'    gem 'rails_12factor'  end    group :test do    gem 'database_cleaner'    gem 'shoulda-matchers', '~> 3.1', '>= 3.1.1'    gem 'launchy'    gem 'selenium-webdriver'    gem 'simplecov', :require => false  end  

rails generate model : incompatible library version error

Posted: 03 Sep 2016 05:58 AM PDT

I am new to ruby on rails and getting errors when trying to generate models. I wrote this command on terminal :

rails generate model Book  

and I got this error:

/var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:6:in `require': incompatible library version - /var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi_c.so (LoadError)  from /var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:6:in `rescue in <top (required)>'  from /var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:3:in `<top (required)>'  from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/native.rb:1:in `require'  from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/native.rb:1:in `<top (required)>'  from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify.rb:1:in `require'  from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify.rb:1:in `<top (required)>'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/linux.rb:30:in `require'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/linux.rb:30:in `_configure'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:45:in `block in configure'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `each'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `configure'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:63:in `start'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/backend.rb:28:in `start'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/listener.rb:67:in `block in <class:Listener>'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `instance_eval'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `call'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:91:in `transition_with_callbacks!'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:57:in `transition'  from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/listener.rb:90:in `start'  from /var/lib/gems/2.3.0/gems/spring-watcher-listen-2.0.0/lib/spring/watcher/listen.rb:27:in `start'  from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:70:in `start_watcher'  from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:79:in `preload'  from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:143:in `serve'  from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'  from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'  from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'  from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'  from /home/pearlstud/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'  from /home/pearlstud/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'  from -e:1:in `<main>'  

I tried adding "therubyracer" in my gemfile and then running,

bundle install  

but even this doesn't help.
My rails version is "Rails 5.0.0.1".

The content of the Gemfile is as follows:

source 'https://rubygems.org'    # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'  gem 'rails', '~> 5.0.0', '>= 5.0.0.1'  # Use sqlite3 as the database for Active Record  gem 'sqlite3'  # Use Puma as the app server  gem 'puma', '~> 3.0'  # Use SCSS for stylesheets  gem 'sass-rails', '~> 5.0'  # Use Uglifier as compressor for JavaScript assets  gem 'uglifier', '>= 1.3.0'  # Use CoffeeScript for .coffee assets and views  gem 'coffee-rails', '~> 4.2'  # See https://github.com/rails/execjs#readme for more supported runtimes  # gem 'therubyracer', platforms: :ruby    # Use jquery as the JavaScript library  gem 'jquery-rails'  # Turbolinks makes navigating your web application faster. Read more:    https://github.com/turbolinks/turbolinks  gem 'turbolinks', '~> 5'  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder  gem 'jbuilder', '~> 2.5'  # Use Redis adapter to run Action Cable in production  # gem 'redis', '~> 3.0'  # Use ActiveModel has_secure_password  # gem 'bcrypt', '~> 3.1.7'  gem 'therubyracer'  # Use Capistrano for deployment  # gem 'capistrano-rails', group: :development    group :development, :test do  # Call 'byebug' anywhere in the code to stop execution and get a debugger console  gem 'byebug', platform: :mri  end    group :development do  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.  gem 'web-console'  gem 'listen', '~> 3.0.5'  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring  gem 'spring'  gem 'spring-watcher-listen', '~> 2.0.0'  end    # Windows does not include zoneinfo files, so bundle the tzinfo-data gem  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]  

The contents of Gemfile.lock is as follows:

    remote: https://rubygems.org/    specs:      actioncable (5.0.0.1)        actionpack (= 5.0.0.1)        nio4r (~> 1.2)        websocket-driver (~> 0.6.1)      actionmailer (5.0.0.1)        actionpack (= 5.0.0.1)        actionview (= 5.0.0.1)        activejob (= 5.0.0.1)        mail (~> 2.5, >= 2.5.4)        rails-dom-testing (~> 2.0)      actionpack (5.0.0.1)        actionview (= 5.0.0.1)        activesupport (= 5.0.0.1)        rack (~> 2.0)        rack-test (~> 0.6.3)        rails-dom-testing (~> 2.0)        rails-html-sanitizer (~> 1.0, >= 1.0.2)      actionview (5.0.0.1)        activesupport (= 5.0.0.1)        builder (~> 3.1)        erubis (~> 2.7.0)        rails-dom-testing (~> 2.0)        rails-html-sanitizer (~> 1.0, >= 1.0.2)      activejob (5.0.0.1)        activesupport (= 5.0.0.1)        globalid (>= 0.3.6)      activemodel (5.0.0.1)        activesupport (= 5.0.0.1)      activerecord (5.0.0.1)        activemodel (= 5.0.0.1)        activesupport (= 5.0.0.1)        arel (~> 7.0)      activesupport (5.0.0.1)        concurrent-ruby (~> 1.0, >= 1.0.2)        i18n (~> 0.7)        minitest (~> 5.1)        tzinfo (~> 1.1)      arel (7.1.1)      builder (3.2.2)      byebug (9.0.5)      coffee-rails (4.2.1)        coffee-script (>= 2.2.0)        railties (>= 4.0.0, < 5.2.x)      coffee-script (2.4.1)        coffee-script-source        execjs      coffee-script-source (1.10.0)      concurrent-ruby (1.0.2)      debug_inspector (0.0.2)      erubis (2.7.0)      execjs (2.7.0)      ffi (1.9.14)      globalid (0.3.7)        activesupport (>= 4.1.0)      i18n (0.7.0)      jbuilder (2.6.0)        activesupport (>= 3.0.0, < 5.1)        multi_json (~> 1.2)      jquery-rails (4.2.1)        rails-dom-testing (>= 1, < 3)        railties (>= 4.2.0)        thor (>= 0.14, < 2.0)      libv8 (3.16.14.15)      listen (3.0.8)        rb-fsevent (~> 0.9, >= 0.9.4)        rb-inotify (~> 0.9, >= 0.9.7)      loofah (2.0.3)        nokogiri (>= 1.5.9)      mail (2.6.4)        mime-types (>= 1.16, < 4)      method_source (0.8.2)      mime-types (3.1)        mime-types-data (~> 3.2015)      mime-types-data (3.2016.0521)      mini_portile2 (2.1.0)      minitest (5.9.0)      multi_json (1.12.1)      nio4r (1.2.1)      nokogiri (1.6.8)        mini_portile2 (~> 2.1.0)        pkg-config (~> 1.1.7)      pkg-config (1.1.7)      puma (3.6.0)      rack (2.0.1)      rack-test (0.6.3)        rack (>= 1.0)      rails (5.0.0.1)        actioncable (= 5.0.0.1)        actionmailer (= 5.0.0.1)        actionpack (= 5.0.0.1)        actionview (= 5.0.0.1)        activejob (= 5.0.0.1)        activemodel (= 5.0.0.1)        activerecord (= 5.0.0.1)        activesupport (= 5.0.0.1)        bundler (>= 1.3.0, < 2.0)        railties (= 5.0.0.1)        sprockets-rails (>= 2.0.0)      rails-dom-testing (2.0.1)        activesupport (>= 4.2.0, < 6.0)        nokogiri (~> 1.6.0)      rails-html-sanitizer (1.0.3)        loofah (~> 2.0)      railties (5.0.0.1)        actionpack (= 5.0.0.1)        activesupport (= 5.0.0.1)        method_source        rake (>= 0.8.7)        thor (>= 0.18.1, < 2.0)      rake (11.2.2)      rb-fsevent (0.9.7)      rb-inotify (0.9.7)        ffi (>= 0.5.0)      ref (2.0.0)      sass (3.4.22)      sass-rails (5.0.6)        railties (>= 4.0.0, < 6)        sass (~> 3.1)        sprockets (>= 2.8, < 4.0)        sprockets-rails (>= 2.0, < 4.0)        tilt (>= 1.1, < 3)      spring (1.7.2)      spring-watcher-listen (2.0.0)        listen (>= 2.7, < 4.0)        spring (~> 1.2)      sprockets (3.7.0)        concurrent-ruby (~> 1.0)        rack (> 1, < 3)      sprockets-rails (3.2.0)        actionpack (>= 4.0)        activesupport (>= 4.0)        sprockets (>= 3.0.0)      sqlite3 (1.3.11)      therubyracer (0.12.2)        libv8 (~> 3.16.14.0)        ref      thor (0.19.1)      thread_safe (0.3.5)      tilt (2.0.5)      turbolinks (5.0.1)        turbolinks-source (~> 5)      turbolinks-source (5.0.0)      tzinfo (1.2.2)        thread_safe (~> 0.1)      uglifier (3.0.2)        execjs (>= 0.3.0, < 3)      web-console (3.3.1)        actionview (>= 5.0)        activemodel (>= 5.0)        debug_inspector        railties (>= 5.0)      websocket-driver (0.6.4)        websocket-extensions (>= 0.1.0)      websocket-extensions (0.1.2)    PLATFORMS    ruby    DEPENDENCIES    byebug    coffee-rails (~> 4.2)    jbuilder (~> 2.5)    jquery-rails    listen (~> 3.0.5)    puma (~> 3.0)    rails (~> 5.0.0, >= 5.0.0.1)    sass-rails (~> 5.0)    spring    spring-watcher-listen (~> 2.0.0)    sqlite3    therubyracer    turbolinks (~> 5)    tzinfo-data    uglifier (>= 1.3.0)    web-console    BUNDLED WITH     1.12.5  

Should development server's configuration be the same with the production server?

Posted: 03 Sep 2016 05:44 AM PDT

I have been learning about AWS to deploy my rails application. It seems AWS Beanstalk is the easiest one I can use for my deployment. It even provides CLI tool so that I may be able to deploy easily as I do in Heroku.

But what I haven't still figured out is whether my development server's configuration should be the same with the production server which is a AWS Beanstalk stack.

For example, is it possible to use a different OS between the development server and production server? Ruby, MySQL, Web server and all other stuffs should be the same?

Why is this scope's lambda followed by a block?

Posted: 03 Sep 2016 06:25 AM PDT

Here is a method described in the Rails API:

scope(name, body, &block)      

This is an example of using that method also described in the Rails API:

class Shirt < ActiveRecord::Base    scope :red, -> { where(color: 'red') } do      def dom_id        'red_shirts'      end    end  end  

The question is about the following code:

do    def dom_id      'red_shirts'    end  end  

What does it stand for? I can't find any Ruby syntax about a block could follow a lambda. Did I miss something? Thanks for any help.

put :update in rspec not updating attributes

Posted: 03 Sep 2016 04:03 AM PDT

I am trying to test the update action of a devise Model in my app.

My factories.rb file:

FactoryGirl.define do    factory :student do      first_name "John"      last_name "Doe"      sequence(:email) { |n| "#{first_name}.#{last_name}#{n}@example.com".downcase }      city "Dhaka"      area "Mirpur"      zip 1216      full_address "Mirpur, Dhaka"      password "password"      password_confirmation "password"      confirmed_at Date.today    end  end  

The rspec file:

require 'rails_helper'    RSpec.describe Students::RegistrationsController do    context "Student logged in" do      before(:each) do        @request.env["devise.mapping"] = Devise.mappings[:student]        @student = FactoryGirl.create(:student)        @updated_attributes = { :first_name => "New", :last_name => "Name" }        sign_in @student        put :update, :id => @student.id, :student => @updated_attributes          @student.reload      end        it { expect(@student.first_name).to eql "New" }      it { expect(@student.last_name).to eql "Name" }    end  end  

I expected the tests to pass. But they are failing. The failing messages look like this:

Failure/Error: it { expect(@student.first_name).to eql "New" }

   expected: "New"          got: "John"       (compared using eql?)  

Failure/Error: it { expect(@student.last_name).to eql "Name" }

   expected: "Name"          got: "Doe"       (compared using eql?)  

So, basically, the attributes are not getting updated. What do i need to do to make rspec update the attributes and make the tests green?

railstutorial: i have create my first asociation (users & posts), but can access posts

Posted: 03 Sep 2016 04:03 AM PDT

After creating an association between users and microposts, we are asked to show the first post in each user show method. Then I do that (in users controller.rb)

 def show    @microposts = User.first.microposts.first   end  

In rails console the query give me back the correct result, but I can't get it in the browser. What am I doing wrong?

The current result is user info instead of first post.

How to temporarily store files on heroku for delayed job import

Posted: 03 Sep 2016 05:49 AM PDT

I have an import functionality in my rails app that imports a CSV file and updates records accordingly. As this file gets bigger, the request takes longer and eventually times out. Therefore I chose to implement delayed_job to handle my long running requests. The only problem is, when the job runs, the error message Errno::ENOENT: No such file or directory is thrown. This is because my solution works with the CSV file in memory.

Is there a way to save the CSV file to my heroku server (and delete it after the import)?

FATAL: Peer authentication failed for user "shop"

Posted: 03 Sep 2016 04:56 AM PDT

What I did:

sudo -u postgres psql  CREATE ROLE shop CREATEDB LOGIN PASSWORD 'kurt1245';  

Then I cloned a repository from GitHub (a rails application which uses pg), bundle install, edit database.yml to write my password and now after rake db:create (also setup and migrate) doesn't work.

database.yml:

development: adapter: postgresql encoding: unicode database: shop_development pool: 5 username: shop password: kurt1245 test: adapter: postgresql encoding: unicode database: shop_test pool: 5 username: shop password: kurt1245

Pointer on class object

Posted: 03 Sep 2016 03:47 AM PDT

In my Ruby model I want to apply default value on somes properties on my Recipe. So I added an before_save callback to apply it: This is my Recipe model:

class Recipe < ActiveRecord::Base      before_save :set_default_time        # other stuff        private        # set default time on t_baking, t_cooling, t_cooking, t_rest if not already set      def set_default_time          zero_time = Time.new 2000, 1 ,1,0,0,0            self.t_baking   = zero_time unless self.t_baking.present?          self.t_cooling  = zero_time unless self.t_cooling.present?          self.t_cooking  = zero_time unless self.t_cooking.present?          self.t_rest     = zero_time unless self.t_rest.present?      end    end  

It's pretty work but I want to factorize it like this:

class Recipe < ActiveRecord::Base      before_save :set_default_time        # other stuff        private        # set default time on t_baking, t_cooling, t_cooking, t_rest if not already set      def set_default_time          zero_time = Time.new 2000, 1 ,1,0,0,0            [self.t_baking, self.t_cooling, self.t_cooking, self.t_rest].each{ |t_time|              t_time = zero_time unless t_time.present?          }        end    end  

But it doesn't work. How can I loop on "pointer" on my object propertie?

Showing different navbar based on devise model

Posted: 03 Sep 2016 07:47 AM PDT

I have an ecommerce app with two different devise models seller and buyer. I am not using subdomains.So this is how each urls looks like

http://localhost:3000/buyers/sign_in    http://localhost:3000/sellers/sign_in  

I am using different devise views for each of these. But I dont want to show the same navbar for the seller and buyer. How can I check if the user is in seller page or buyer page and show a navbar based on that from application.html.erb?

I first thought about showing navbar based on the controller but as devise uses same controllers and actions for all models am bit confused here.

I am using different views for buyers and sellers so is it possible to pass a variable or something to application.html.erb from each page(like login,signup) to show the correct navbar?

Rails - Ruby version same as gemfile specification but still getting error

Posted: 03 Sep 2016 05:36 AM PDT

When I run rails c, I get the following error:

Your Ruby version is 2.0.0, but your Gemfile specified 2.2.3

When I run ruby -v, I get the following output:

ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14].

My gemfile includes this:

ruby '2.2.3'  

Why am I receiving this error if I'm using the same ruby version that's specified in my gemfile?

Edit:

I've tried the solution from this question (to run gem install bundler or gem update bundler), with no success.

I'm using rvm, and my rvm list output is:

rvm rubies       ruby-2.0.0-p643 [ x86_64 ]     ruby-2.1.1 [ x86_64 ]     ruby-2.2.0 [ x86_64 ]     ruby-2.2.2 [ x86_64 ]  =* ruby-2.2.3 [ x86_64 ]     ruby-2.3.0 [ x86_64 ]    # => - current  # =* - current && default  #  * - default  

Gemfile.lock:

GIT    remote: git://github.com/thedarkone/rails-dev-boost.git    revision: a709a10b06b7d9fc4a9846bc613c60c86af9dd7c    specs:      rails-dev-boost (0.3.0)        railties (>= 3.0)    GEM    remote: https://rubygems.org/    specs:      actionmailer (4.2.6)        actionpack (= 4.2.6)        actionview (= 4.2.6)        activejob (= 4.2.6)        mail (~> 2.5, >= 2.5.4)        rails-dom-testing (~> 1.0, >= 1.0.5)      actionpack (4.2.6)        actionview (= 4.2.6)        activesupport (= 4.2.6)        rack (~> 1.6)        rack-test (~> 0.6.2)        rails-dom-testing (~> 1.0, >= 1.0.5)        rails-html-sanitizer (~> 1.0, >= 1.0.2)      actionview (4.2.6)        activesupport (= 4.2.6)        builder (~> 3.1)        erubis (~> 2.7.0)        rails-dom-testing (~> 1.0, >= 1.0.5)        rails-html-sanitizer (~> 1.0, >= 1.0.2)      activejob (4.2.6)        activesupport (= 4.2.6)        globalid (>= 0.3.0)      activemodel (4.2.6)        activesupport (= 4.2.6)        builder (~> 3.1)      activerecord (4.2.6)        activemodel (= 4.2.6)        activesupport (= 4.2.6)        arel (~> 6.0)      activesupport (4.2.6)        i18n (~> 0.7)        json (~> 1.7, >= 1.7.7)        minitest (~> 5.1)        thread_safe (~> 0.3, >= 0.3.4)        tzinfo (~> 1.1)      addressable (2.4.0)      arel (6.0.3)      autoprefixer-rails (6.3.6.1)        execjs      bcrypt (3.1.11)      binding_of_caller (0.7.2)        debug_inspector (>= 0.0.1)      bootstrap-sass (3.3.6)        autoprefixer-rails (>= 5.2.1)        sass (>= 3.3.4)      bootstrap3-datetimepicker-rails (4.17.37)        momentjs-rails (>= 2.8.1)      builder (3.2.2)      byebug (9.0.3)      capybara (2.7.1)        addressable        mime-types (>= 1.16)        nokogiri (>= 1.3.3)        rack (>= 1.0.0)        rack-test (>= 0.5.4)        xpath (~> 2.0)      climate_control (0.0.3)        activesupport (>= 3.0)      cocaine (0.5.8)        climate_control (>= 0.0.3, < 1.0)      coderay (1.1.1)      coffee-rails (4.1.1)        coffee-script (>= 2.2.0)        railties (>= 4.0.0, < 5.1.x)      coffee-script (2.4.1)        coffee-script-source        execjs      coffee-script-source (1.10.0)      concurrent-ruby (1.0.2)      cookiejar (0.3.0)      css_parser (1.3.7)        addressable      daemons (1.2.3)      database_cleaner (1.5.3)      debug_inspector (0.0.2)      devise (4.1.1)        bcrypt (~> 3.0)        orm_adapter (~> 0.1)        railties (>= 4.1.0, < 5.1)        responders        warden (~> 1.2.3)      diff-lcs (1.2.5)      dropzonejs-rails (0.7.3)        rails (> 3.1)      em-http-request (1.1.3)        addressable (>= 2.3.4)        cookiejar (<= 0.3.0)        em-socksify (>= 0.3)        eventmachine (>= 1.0.3)        http_parser.rb (>= 0.6.0)      em-socksify (0.3.1)        eventmachine (>= 1.0.0.beta.4)      erubis (2.7.0)      eventmachine (1.2.0.1)      execjs (2.6.0)      factory_girl (4.7.0)        activesupport (>= 3.0.0)      factory_girl_rails (4.7.0)        factory_girl (~> 4.7.0)        railties (>= 3.0.0)      faker (1.6.3)        i18n (~> 0.5)      faraday (0.9.2)        multipart-post (>= 1.2, < 3)      faye (1.1.2)        cookiejar (>= 0.3.0)        em-http-request (>= 0.3.0)        eventmachine (>= 0.12.0)        faye-websocket (>= 0.9.1)        multi_json (>= 1.0.0)        rack (>= 1.0.0)        websocket-driver (>= 0.5.1)      faye-websocket (0.10.4)        eventmachine (>= 0.12.0)        websocket-driver (>= 0.5.1)      ffi (1.9.12)      figaro (1.1.1)        thor (~> 0.14)      font-awesome-rails (4.6.3.0)        railties (>= 3.2, < 5.1)      formatador (0.2.5)      globalid (0.3.6)        activesupport (>= 4.1.0)      guard (2.14.0)        formatador (>= 0.2.4)        listen (>= 2.7, < 4.0)        lumberjack (~> 1.0)        nenv (~> 0.1)        notiffany (~> 0.0)        pry (>= 0.9.12)        shellany (~> 0.0)        thor (>= 0.18.1)      guard-compat (1.2.1)      guard-rspec (4.7.2)        guard (~> 2.1)        guard-compat (~> 1.1)        rspec (>= 2.99.0, < 4.0)      hashie (3.4.4)      http_parser.rb (0.6.0)      httpclient (2.8.2.3)      i18n (0.7.0)      jbuilder (2.4.1)        activesupport (>= 3.0.0, < 5.1)        multi_json (~> 1.2)      jquery-rails (4.1.1)        rails-dom-testing (>= 1, < 3)        railties (>= 4.2.0)        thor (>= 0.14, < 2.0)      jquery-turbolinks (2.1.0)        railties (>= 3.1.0)        turbolinks      jquery-ui-rails (5.0.5)        railties (>= 3.2.16)      json (1.8.3)      jwt (1.5.1)      launchy (2.4.3)        addressable (~> 2.3)      listen (3.1.5)        rb-fsevent (~> 0.9, >= 0.9.4)        rb-inotify (~> 0.9, >= 0.9.7)        ruby_dep (~> 1.2)      loofah (2.0.3)        nokogiri (>= 1.5.9)      lumberjack (1.0.10)      mail (2.6.4)        mime-types (>= 1.16, < 4)      method_source (0.8.2)      mime-types (3.0)        mime-types-data (~> 3.2015)      mime-types-data (3.2016.0221)      mimemagic (0.3.0)      mini_portile2 (2.0.0)      minitest (5.8.4)      momentjs-rails (2.11.1)        railties (>= 3.1)      multi_json (1.12.0)      multi_xml (0.5.5)      multipart-post (2.0.0)      nenv (0.3.0)      nokogiri (1.6.7.2)        mini_portile2 (~> 2.0.0.rc2)      notiffany (0.1.0)        nenv (~> 0.1)        shellany (~> 0.0)      oauth2 (1.1.0)        faraday (>= 0.8, < 0.10)        jwt (~> 1.0, < 1.5.2)        multi_json (~> 1.3)        multi_xml (~> 0.5)        rack (>= 1.2, < 3)      omniauth (1.3.1)        hashie (>= 1.2, < 4)        rack (>= 1.0, < 3)      omniauth-facebook (3.0.0)        omniauth-oauth2 (~> 1.2)      omniauth-oauth2 (1.4.0)        oauth2 (~> 1.0)        omniauth (~> 1.2)      omniauth-stripe-connect (2.3.0)        omniauth (~> 1.0)        omniauth-oauth2 (>= 1.0.3)      orm_adapter (0.5.0)      paperclip (4.3.6)        activemodel (>= 3.2.0)        activesupport (>= 3.2.0)        cocaine (~> 0.5.5)        mime-types        mimemagic (= 0.3.0)      pg (0.18.4)      phony (2.15.21)      phony_rails (0.14.1)        activesupport (>= 3.0)        phony (~> 2.12)      private_pub (1.0.3)        faye      pry (0.10.3)        coderay (~> 1.1.0)        method_source (~> 0.8.1)        slop (~> 3.4)      public_activity (1.5.0)        actionpack (>= 3.0.0)        activerecord (>= 3.0)        i18n (>= 0.5.0)        railties (>= 3.0.0)      pusher (1.1.0)        httpclient (~> 2.7)        multi_json (~> 1.0)        pusher-signature (~> 0.1.8)      pusher-signature (0.1.8)      rack (1.6.4)      rack-test (0.6.3)        rack (>= 1.0)      rails (4.2.6)        actionmailer (= 4.2.6)        actionpack (= 4.2.6)        actionview (= 4.2.6)        activejob (= 4.2.6)        activemodel (= 4.2.6)        activerecord (= 4.2.6)        activesupport (= 4.2.6)        bundler (>= 1.3.0, < 2.0)        railties (= 4.2.6)        sprockets-rails      rails-deprecated_sanitizer (1.0.3)        activesupport (>= 4.2.0.alpha)      rails-dom-testing (1.0.7)        activesupport (>= 4.2.0.beta, < 5.0)        nokogiri (~> 1.6.0)        rails-deprecated_sanitizer (>= 1.0.1)      rails-html-sanitizer (1.0.3)        loofah (~> 2.0)      railties (4.2.6)        actionpack (= 4.2.6)        activesupport (= 4.2.6)        rake (>= 0.8.7)        thor (>= 0.18.1, < 2.0)      rake (11.1.2)      rb-fsevent (0.9.7)      rb-inotify (0.9.7)        ffi (>= 0.5.0)      rdoc (4.2.2)        json (~> 1.4)      responders (2.2.0)        railties (>= 4.2.0, < 5.1)      rest-client (1.6.7)        mime-types (>= 1.16)      roadie (3.1.1)        css_parser (~> 1.3.4)        nokogiri (>= 1.5.0, < 1.7.0)      roadie-rails (1.1.1)        railties (>= 3.0, < 5.1)        roadie (~> 3.1)      rspec (3.0.0)        rspec-core (~> 3.0.0)        rspec-expectations (~> 3.0.0)        rspec-mocks (~> 3.0.0)      rspec-core (3.0.4)        rspec-support (~> 3.0.0)      rspec-expectations (3.0.4)        diff-lcs (>= 1.2.0, < 2.0)        rspec-support (~> 3.0.0)      rspec-mocks (3.0.4)        rspec-support (~> 3.0.0)      rspec-rails (3.0.2)        actionpack (>= 3.0)        activesupport (>= 3.0)        railties (>= 3.0)        rspec-core (~> 3.0.0)        rspec-expectations (~> 3.0.0)        rspec-mocks (~> 3.0.0)        rspec-support (~> 3.0.0)      rspec-support (3.0.4)      ruby_dep (1.3.1)      sass (3.4.22)      sass-rails (5.0.4)        railties (>= 4.0.0, < 5.0)        sass (~> 3.1)        sprockets (>= 2.8, < 4.0)        sprockets-rails (>= 2.0, < 4.0)        tilt (>= 1.1, < 3)      sdoc (0.4.1)        json (~> 1.7, >= 1.7.7)        rdoc (~> 4.0)      shellany (0.0.1)      slop (3.6.0)      sprockets (3.6.0)        concurrent-ruby (~> 1.0)        rack (> 1, < 3)      sprockets-rails (3.0.4)        actionpack (>= 4.0)        activesupport (>= 4.0)        sprockets (>= 3.0.0)      sqlite3 (1.3.11)      stripe (1.43.0)        rest-client (~> 1.4)      thin (1.7.0)        daemons (~> 1.0, >= 1.0.9)        eventmachine (~> 1.0, >= 1.0.4)        rack (>= 1, < 3)      thor (0.19.1)      thread_safe (0.3.5)      tilt (2.0.4)      toastr-rails (1.0.3)        railties (>= 3.1.0)      turbolinks (2.5.3)        coffee-rails      twilio-ruby (4.11.1)        builder (>= 2.1.2)        jwt (~> 1.0)        multi_json (>= 1.3.0)      tzinfo (1.2.2)        thread_safe (~> 0.1)      uglifier (3.0.0)        execjs (>= 0.3.0, < 3)      warden (1.2.6)        rack (>= 1.0)      web-console (2.3.0)        activemodel (>= 4.0)        binding_of_caller (>= 0.7.2)        railties (>= 4.0)        sprockets-rails (>= 2.0, < 4.0)      websocket-driver (0.6.4)        websocket-extensions (>= 0.1.0)      websocket-extensions (0.1.2)      xpath (2.0.0)        nokogiri (~> 1.3)    PLATFORMS    ruby    DEPENDENCIES    bootstrap-sass (~> 3.3.6)    bootstrap3-datetimepicker-rails (~> 4.17.37)    byebug    capybara    coffee-rails (~> 4.1.0)    database_cleaner    devise    dropzonejs-rails    factory_girl_rails    faker    figaro    font-awesome-rails    guard-rspec    jbuilder (~> 2.0)    jquery-rails    jquery-turbolinks    jquery-ui-rails    launchy    momentjs-rails (>= 2.9.0)    omniauth    omniauth-facebook    omniauth-stripe-connect    paperclip    pg    phony_rails    private_pub    public_activity    pusher    rails (= 4.2.6)    rails-dev-boost!    rb-fsevent (>= 0.9.1)    roadie-rails (~> 1.0)    rspec-rails    sass-rails (>= 3.2)    sdoc (~> 0.4.0)    sqlite3    stripe    thin    toastr-rails    turbolinks    twilio-ruby (~> 4.11.1)    uglifier (>= 1.3.0)    web-console (~> 2.0)    RUBY VERSION     ruby 2.2.3p173    BUNDLED WITH     1.12.5  

rails: different view templates for each model

Posted: 03 Sep 2016 03:21 AM PDT

I have a Section model with multiple subclasses: TextSection, PictureSection, etc. I use Single Table Inheritance and Rails 5.

Each section type is displayed differently, but I'd like to do something like this pseudo code in my view:

<% for @page.sections.each do |section|%>    <%= section.display %>  <% end %>  

and for the edition:

<% for @page.sections.each do |section|%>    <%= section.display_form %>  <% end %>  

What's the rails way to achieve this? Can I attach or embedd a template to the model?

Paperclip is providing defferent attachment URL

Posted: 03 Sep 2016 03:18 AM PDT

http://s3.amazonaws.com/demo1990/download-uploads/uploads/files/000/000/034/original/Screenshot_from_2016-07-29_20_48_49.png  

instead of

https://s3.ap-south-1.amazonaws.com/demo1990/download-uploads/uploads/files/000/000/034/original/Screenshot_from_2016-07-29_20_48_49.png   

My model is

has_attached_file :file,     :url => 'demo1990.s3-website.ap-south-1.amazonaws.com',     :path => '/download-uploads/:class/:attachment/:id_partition/:style/:filename'    validates_attachment_content_type :file,    :presence => true,     :content_type => ["application/zip", "application/pdf","application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "image/png", "image/jpeg", "image/gif", "image/tiff", "text/plain","video/mp4","video/avi","audio/mpeg","audio/mp3"]  

Thanks

Authentication: JWT in RoR and android

Posted: 03 Sep 2016 05:56 AM PDT

Ruby 2.2.4 Rails 5.0.0.1 retrofit:1.9.0' otto:1.3.8'

Hello People,

I am just a beginner in programming and I have the task to create an android app with Android Studio, where you can login and logout as a user. Therefore I programmed a Token-based authentication in RoR 5 API with Json Web Token (JWT). This tutorial helped me: http://tutorials.pluralsight.com/ruby-ruby-on-rails/token-based-authentication-with-ruby-on-rails-5-api ). After putting the right credentials in curl I finally receive the token: {"auth_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE0NjA2NTgxODZ9.xsSwcPC22IR71OBv6bU_OGCSyfE89DvEzWfDU0iybMA"}

Now after this works fine I tried to implemend the login-function in android studio, which should interact with my RoR server. I followed strictly a tutorial (https://www.sitepoint.com/retrofit-a-simple-http-client-for-android-and-java/ )which uses Retrofit for authentication with a php server. However I want to implement this for my RoR server. Nevertheless I tried this code out. I was happy, that the program can communicate with my ruby on rails server. If I login on android app with the right credentials, I see on the console that it will be accepted.

However I dont know how I get a message on android, that the login was succesful plus a welcome message with the name of the user. As I said I use JWT in RoR which gives a long token back. Is there a possibility that retrofit can interpret this token? Or do I need to install JSON Web Token for android? Here is a part of the code in ruby on rails:

app/commands/authenticate_user.rb

class AuthenticateUser    prepend SimpleCommand      def initialize(email, password)      @email = email      @password = password    end      def call  JsonWebToken.encode(user_id: user.id) if user    end      private      attr_accessor :email, :password      def user      user = User.find_by_email(email)      return user if user && user.authenticate(password)        errors.add :user_authentication, 'invalid credentials'      nil    end  end  

lib/json_web_token.rb

class JsonWebToken    class << self      def encode(payload, exp = 24.hours.from_now)        payload[:exp] = exp.to_i        JWT.encode(payload, Rails.application.secrets.secret_key_base)      end        def decode(token)        body = JWT.decode(token, Rails.application.secrets.secret_key_base)[0]        HashWithIndifferentAccess.new body      rescue        nil      end    end  end  

And here comes a part of my android app, which code is from the tutorial I followed:

public class Communicator {      private static  final String TAG = "Communicator";      private static final String SERVER_URL = "http://127.0.0.1/retrofit";        public void loginPost(String username, String password){          RestAdapter restAdapter = new RestAdapter.Builder()                  .setEndpoint(SERVER_URL)                  .setLogLevel(RestAdapter.LogLevel.FULL)                  .build();          Interface communicatorInterface = restAdapter.create(Interface.class);          Callback<ServerResponse> callback = new Callback<ServerResponse>() {              @Override              public void success(ServerResponse serverResponse, Response response2) {                  if(serverResponse.getResponseCode() == 0){                      BusProvider.getInstance().post(produceServerEvent(serverResponse));                  }else{                      BusProvider.getInstance().post(produceErrorEvent(serverResponse.getResponseCode(), serverResponse.getMessage()));                  }                }                @Override              public void failure(RetrofitError error) {                  if(error != null ){                      Log.e(TAG, error.getMessage());                      error.printStackTrace();                  }                  BusProvider.getInstance().post(produceErrorEvent(-200,error.getMessage()));              }          };          communicatorInterface.postData("login", username, password, callback);      }        public void loginGet(String username, String password){          RestAdapter restAdapter = new RestAdapter.Builder()                  .setEndpoint(SERVER_URL)                  .setLogLevel(RestAdapter.LogLevel.FULL)                  .build();          Interface communicatorInterface = restAdapter.create(Interface.class);          Callback<ServerResponse> callback = new Callback<ServerResponse>() {              @Override              public void success(ServerResponse serverResponse, Response response2) {                  if(serverResponse.getResponseCode() == 0){                      BusProvider.getInstance().post(produceServerEvent(serverResponse));                  }else{                      BusProvider.getInstance().post(produceErrorEvent(serverResponse.getResponseCode(), serverResponse.getMessage()));                  }              }                @Override              public void failure(RetrofitError error) {                  if(error != null ){                      Log.e(TAG, error.getMessage());                      error.printStackTrace();                  }                  BusProvider.getInstance().post(produceErrorEvent(-200,error.getMessage()));              }          };          communicatorInterface.getData("login", username, password, callback);      }  }  

This is the Php script from the android tutorial. Maybe I need to transfer this into ruby

<?php        //Post Method here      if(isset($_POST['method']) == 'login'){          $username = $_POST['username'];          $password = $_POST['password'];            if($username == "admin" && $password == "admin"){              $response = array('returned_username' => "-admin-",                                'returned_password' => "-admin-",                                'message' => "Your credentials are so weak [USING_POST]!",                                'response_code' => "1");                 echo json_encode($response);            }else{              $response = array('response_code' => "-1",                                'message' => "invalid username or password");                 echo json_encode($response);          }      }  

The json encoding in php includes an array (username, password, message, responsecode). How can I include the same array with JWT on ruby on rails? Any idea? And how I get a message on android, that the login was succesful

Unable to grab the same ID inside the form while edit action - Ruby on Rails

Posted: 03 Sep 2016 02:55 AM PDT

I have an Invoices app so that users can create the invoices.

The issue is when I create a New Invoice it's ID is 1 ( http://localhost:3000/invoices/1 ) as this is the first invoice that is Invoice # 1 but when I go to Edit link it still shows ( http://localhost:3000/invoices/1/edit ) but with Invoice # 2, as it must grab the same ID i.e.,1 retaining Invoice # 1.

Here's an screenshot as below;

screenshot.png

_form.html.erb

<div class="form-group">      <div class="col-xs-4"><label>Invoice #</label></div>      <div class="col-xs-8 invoice_num"><span id="invoice_number"><%= (Invoice.last.present? ? (Invoice.last.id + 1) : 1) %></span></div>  </div>  

I don't know where I making the mistake.

Any suggestions are most welcome.

Thank you in advance.

How can I do this: Please register a mime type using `register_mime_type` then use `register_compressor` or `register_transformer`

Posted: 03 Sep 2016 02:40 AM PDT

I receive this message when I run rake db:migrate

macpro:rp-blogRails jpcpamies$ rake db:migrate  DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.  Please register a mime type using `register_mime_type` then  use `register_compressor` or `register_transformer`.  https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors  (called from setup at /Users/jpcpamies/.rvm/gems/ruby-2.2.1/gems/stylus-1.0.1/lib/stylus/sprockets.rb:42)  DEPRECATION WARNING: You are using the a deprecated processor interface Stylus::ImportProcessor.  Please update your processor interface:  https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors  (called from setup at /Users/jpcpamies/.rvm/gems/ruby-2.2.1/gems/stylus-1.0.1/lib/stylus/sprockets.rb:43)  

I get that I need to register a mime type using register_mime_type then use register_compressor or register_transformer.

OK! How do I do that??

PS: I have done already

bundle update  

And I am running already

Using sass 3.4.22  Using sass-rails 5.0.6  

Basic javascript ; alert on click

Posted: 03 Sep 2016 02:55 AM PDT

Trying to teach myself how to use js in rails and I found a good video on the topic but somehow it does not work for me and I can not figure out why.

app/views/static_pages/help.html.erb:

...  <p><%= link_to "Description", "#", id: "desc-link" %></p>  ...  

app/javascripts/static_pages.coffee:

$(document).on "page:change", ->      $("#desc-link").click ->          alert "Done!"  

If I click on the link, nothing happens (no error either).

Rails 5 API POST Create params empty

Posted: 03 Sep 2016 02:48 AM PDT

thanks for taking at look at this issue. I'm building an API in Rails 5, and having trouble with the a POST create request.

Basically, my params are empty by the time my API gets them and not sure why. Sending this JSON object with Postman:

{     "battle": {      "winner_score": 300,      "loser_score": 3,      "winner_id": 2,      "loser_id": 1    }  }  

Here's the relevant controller:

class Api::V1::BattlesController < ApplicationController      protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format.include? 'application/json' }    wrap_parameters format: [:json]        # POST /battles    def create      @battle = Battle.new(battle_params)        if @battle.save        render json: @battle, status: :created, location: @battle      else        render json: @battle.errors, status: :unprocessable_entity      end    end      private      # Only allow a trusted parameter "white list" through.    def battle_params      binding.pry      params.permit(:winner_score, :loser_score, :winner_id, :loser_id)    end  end  

When I hit the binding.pry in the battle_params method, the params object is nil:

    50: def battle_params   => 51:   binding.pry      52:   params = params.to_h      53:   params.permit(:winner_score, :loser_score, :winner_id, :loser_id)      54: end        params      => nil  

My Postman request gets a response that says .permit is an undefined method on the hash, which I also see in the terminal:

"status":500,"error":"Internal Server Error","exception":"#\u003cNoMethodError: undefined method `permit' for {}:Hash\u003e"    NoMethodError (undefined method `permit' for {}:Hash):  app/controllers/api/v1/battles_controller.rb:53:in `battle_params'  

I haven't run across this issue before, so any insight is really appreciated.

How to target a model and access records nested two levels deep in Ruby on Rails?

Posted: 03 Sep 2016 02:17 AM PDT

I am trying to create a todo list application in ruby on rails that has 3 models as nested resources.

For Example:

  • User: has_many :todo_lists
  • TodoList: has_many :todo_items & belongs_to :user
  • TodoItem: belongs_to :todo_list & scope :completed, -> { where.not(completed_at: nil) }

Running @user.todo_lists returns the user's todo lists.

Running @todo_lists.todo_items returns the todo list's todo items.

Running @todo_lists.todo_items.completed returns the todo list's completed todo items.

But

Running @user.todo_lists.todo_items returns error: NoMethodError: undefined method 'todo_items'.

Running @user.todo_lists.todo_items.completed also returns error: NoMethodError: undefined method 'todo_items'.

We have tried @user.todo_lists.map(&:todo_items).flatten which returns all the todo items for a user but we cannot add the .completed scope.

Am I on the right track?

Cannot require react-router-rails in plugin engine

Posted: 03 Sep 2016 01:40 AM PDT

I'm writing a little CMS plugin and I decided to use React.js for frontend. Thus I added react-rails and react-router-rails to my .gemspec file. Here it is:

s.add_dependency 'react-rails'  s.add_dependency 'react-router-rails'  

And then in my engine.rb:

require 'react-rails'  require 'react-router-rails'  

But when I try to do anything -- for example, create a model, it returns me the following error:

path_to_my_cms/lib/multiflora/engine.rb:5:in `require': cannot load such file -- react_router_rails (LoadError)  

When I comment the require 'react-router-rails' line out or remove it, everything works. What am I doing wrong? Or this gem isn't supposed to work in plugins?

Passing multiple arguments to Rack middleware in Rails application.rb

Posted: 03 Sep 2016 02:24 AM PDT

I am creating a Rack Middleware which I want to use in my Rails App. Basically, I need to log requests matching particular urls to my Database. In order to do this I need to pass database configuration to my Middleware so it can establish connection with DB. I am trying to do:-

db_yml = Rails.root.join('config/database.yml')  db_config = YAML.load(db_yml.read)[Rails.env]  

But this is giving an error

config/application.rb:40:in <class:Application>': undefined methodread' for # (NoMethodError)

If I add byebug and run the same in the byebug console it works fine. I am not able to find out why. I want to do following things:-

  1. I need to read & modify the database configuration before passing it to my middleware as argument.
  2. I want to read the domain of the request url. We are using Apartment gem and Our schema name will be the domain name.

I followed multiple articles here & here. I am a newbie to Rails and don't know good resources so please help. Thanks in advance!

Can't access ActiveRecord relations with "includes" in Rails 5 project

Posted: 03 Sep 2016 02:33 AM PDT

I'm using Rails 5 with a MySQL database and this is how my models look like:

class User < ApplicationRecord    has_many :user_activities  end  # Table: "users"    class UserActivity < ApplicationRecord    belongs_to :user  end  # Table: "user_activities"  

To make it clear what I'd like to achieve, I'm going to show you an actually working query at first:

SELECT * FROM user_activities LEFT JOIN users ON users.id = user_activities.user_id WHERE (users.gender = 'female') LIMIT 1;  

Nothing too special, right? The problem is that I don't really get this working in my Rails project. I read a few articles already but somehow I got stuck...

ua = UserActivity.includes(:user).where(users: {gender: 'female'}).limit(1) # <-- The "join" part of it works  # ua = UserActivity.includes(:user).where("users.gender = 'f'").limit(1) # <-- MySQL throws an error  puts ua.inspect # <-- Shows me only the attributes of my UserActivity class    puts ua.user.inspect # <-- Can't access anything  

So my question is why I can not use "ua.user"?

Why is su using a different ruby version compared to when I'm logged in as the actual user?

Posted: 03 Sep 2016 03:22 AM PDT

I'm trying to deploy a Ruby on Rails application using nginx and unicorn. When I try to run my unicorn init script, I get the following error:

$ sudo service rails_app start  Starting rails_app  -su: bundle: command not found  

It fails to run on this command:

su - complab -c "bundle exec unicorn -c config/unicorn.rb -E production -D"  

However, running unicorn manually while logged in as $USER works just fine:

$ bundle exec unicorn -c config/unicorn.rb -E production  

I have verified that the path set on the init script is correct. On further investigation, I discovered that while $USER has ruby version 2.2.0 installed via rbenv, running su - $USER -c "ruby -v" shows that it's running on 1.9.3.

I have already run rbenv global 2.2.0 but still it doesn't work.

I thought su meant I was able to temporarily changing the user who owns the session? Why is it that su $USER shows a different ruby version from when I am actually logged in as $USER?

Hope you can help me out!

2 comments:

  1. After reading this blog I very strong in this topics and this blog really helpful to all.Ruby on Rails Online Training

    ReplyDelete
  2. Rails 5 Actioncontroller::Routingerror No Route Matches [Post] "/Auth/Sign_Up" >>>>> Download Now

    >>>>> Download Full

    Rails 5 Actioncontroller::Routingerror No Route Matches [Post] "/Auth/Sign_Up" >>>>> Download LINK

    >>>>> Download Now

    Rails 5 Actioncontroller::Routingerror No Route Matches [Post] "/Auth/Sign_Up" >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete