Tuesday, January 17, 2017

Using pry-rescue with rspec shows strange code point | Fixed issues

Using pry-rescue with rspec shows strange code point | Fixed issues


Using pry-rescue with rspec shows strange code point

Posted: 17 Jan 2017 08:07 AM PST

We are trying to use pry-rescue inside of rspec to get a debugger when a spec fails.

Now when this expectation fails:

 expect(page).to have_content('Thanks for signing up!')  

pry does open, but the code point that pry is at looks like this:

From: /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/pry-rescue-1.4.4/lib/pry-rescue.rb @ line 206 PryRescue.with_program_name:       201: def with_program_name name     202:   before = $PROGRAM_NAME     203:   $PROGRAM_NAME = name     204:   yield     205: ensure  => 206:   $PROGRAM_NAME = before     207: end  

which is obviously not the code of the failing spec. From here on we can only go "up".

We expected to end right at the failing spec (as e.g. pointed out here: Start ruby debugger if rspec test fails).

Why does the above happen instead what did we do wrong?

We are using rspec 3.4.0, pry 0.10.3 and pry-rescue 1.4.4.

undefined method `>' for nil:NilClass when using 'time_ago_in_words' in Rails

Posted: 17 Jan 2017 08:03 AM PST

I'm getting a strange error when trying to use the 'time_ago_in_words' function on conversation.messages.first(created_at) in rails:

<% conversations.each do |conversation| %>    <% user_status = current_user.id == conversation.sender.id ? conversation.recipient : conversation.sender %>    <li>      <%= gravatar_for(user_status, size: 50) %>      <%= link_to user_status.email, conversation_messages_path(conversation),          remote: true,          class: "conversation-names #{'current-link' if conversation == conversations.first}" %>      <span class="delete-message"><%= link_to do %><i class="fa fa-times"></i><% end %></span>      <p><%= truncate(conversation.messages.first.try(:body)) %><%= time_ago_in_words conversation.messages.first.try(:created_at) %></p>    </li>  <% end %>  

undefined method `>' for nil:NilClass.

Rail custom delayed job queue with variable name

Posted: 17 Jan 2017 07:53 AM PST

In my project I have some Delayed Jobs that take a while to process. While few people uses server, that's not a problem to run all of them in one queue (other Jobs run in another queue, surely). But I'm afraid about this if number of users rise. Every job will execute longer and longer because of waiting.

So I thought what if I create queues with variable names? Smth like

def queue_name    "queue_#{Time.now}"  end  

All below is actual only in case previous solution is making sense. Ok, if it could be done using Time. But what about I want to put job into queue with user id in name? I mean one queue per user.

def queue_name(user_id) #what id it could be passed here somehow?..    "user_#{user_id}"  end  

Thanx!

Completely reload a model loaded into an @var (incl. manually changed attr_accessors)

Posted: 17 Jan 2017 07:37 AM PST

I do some manual caching in my models like this:

model User    def status      @status ||= complex_status_computation    end  end  

In specs, I sometimes need to reload a model completely so this cache isn't there anymore. I tried it using

@user.reload  

But this seems only to reload the database fields, and it doesn't reset my manual caches. Is there a better way than doing a manual reset like this?

@user = User.find(@user.id)  

Error while iterating through params

Posted: 17 Jan 2017 08:07 AM PST

I get an error when I try to iterate through params

When running code below:

def create_score    @quiz = Test.find_by(password: session[:test_password])    @points = 0    @quiz.tasks.each_with_index do |task, index|      @task = Task.find_by(id: task)      @points += @task.score if @task.correct_answers.to_s == send("params[:test][:task#{index}]")    end    @score = Score.new(user_id: 2, name: "Test1", points: @points)    if @score.save      redirect_to root_url    else      redirect_to signup_path    end  end  

I get:

undefined method `params[:test][:task0]' ...  

at the

@points += @task.score if @task.correct_answers.to_s == send("params[:test][:task#{index}]")  

Which means that it has problem with send method

Parameters look like this:

{"utf8"=>"✓",   "authenticity_token"=>"8h7rtv2yWio11DFo6kBKutdZl7RDBBaTrt7e8qel8fR5R5XsoXRhRrBeDQPPoZeuBlZ7N5PmqCxik06Z/gQLZQ==",   "test"=>{"task0"=>["4"], "task1"=>["0"], "task2"=>["10"]},   "commit"=>"Zakończ test",   "locale"=>"pl"}  

Which means that there is params[:test][:task0], but still for some reason it fires an error, but I don't really know why. Any ideas why this happens?

Rails 5: How to set an object's attributes using link_to, without any controllers

Posted: 17 Jan 2017 07:30 AM PST

I am trying to update an object titled Dog which has the attribute name. I wish to do so with using any controller methods, currently I am trying this:

<%= link_to 'Delete Name', dog_path(@dog:{name: nil}), method: :patch %>

This keeps giving me a syntax error but I've tried everything I can.

Also, I am aware that it is possible to define a function (in this case titled "delete_name") in the controller and use the following:

<%= link_to 'Delete Name', controller: "dogs", action: "delete_name", id: @dog %>

But I wish to use the first method. Any help is appreciated!

Stucked in the model migration in Ruby on Rails

Posted: 17 Jan 2017 07:29 AM PST

I am new to Rails, so please don't think I am not good in Ruby, because I am still learning. I have a problem during migrating 3 models (Game,Page,Section), which is I created 3 models and forget to save it, then directly migrate it. After that, I created a new model called User, then save it, and this User model perfectly saved and migrated successfully. After that when checked schema, those 3 models did not have any fields and did not migrated.

So I did the rake db:rollback, it only rollback to User Model, but I want those 3 Models to be rollbacked. I cannot do new migration to put new values.

Q1 : So do I need to delete those 3 models and create new models?

RubyOnRails tutorial: sample_app no delete link

Posted: 17 Jan 2017 07:34 AM PST

I'm on step 10.4.2 and coded the delete link and no delete links appear? I tried logging out and back in to no avail. I see no errors on the server.

Added this:

<% if current_user.admin? && !current_user?(user) %>      | <%= link_to "delete", user, method: :delete,                                    data: { confirm: "You sure?" } %>    <% end %>  

I figured it out- it wasn't in the html code- it was that I wasn't logged in as the current admin person who has authority to delete-

current_user.admin?  

How to hide a column in pry / rails output

Posted: 17 Jan 2017 07:38 AM PST

I have an image blob written to a field in the db, but I don't want to see that output in a console when I view the user object.

I don't need the output changed or modified for the functioning of the application this is JUST for debugging / developing with the console. I did attempt some of the serialization concepts but they aren't helpful for these purposes. I also looked into filter_parameters which only are helpful for logging and not pry console output.

I am using the pry-rails gem for the rails console, if that changes anything.

No route matches [POST] "/tracking_configs/6" after submitting another remote form

Posted: 17 Jan 2017 07:21 AM PST

I am working at the view for an edit action which contains one primary form for the model TrackingConfig, which submits normally (not remote), and another secondary remote form for fetching some data.

= form_for @tracking_config do |f|      .event-fields      = f.fields_for :tracking_event_configs do |ff|        = render 'tracking_event_config_block', form: ff      = f.submit 'Save', class: 'btn btn-danger'      = form_tag get_event_fields_tracking_configs_path, remote: true, method: :get do    = select_tag :event_name, options_from_collection_for_select(TrackableEvent.all, :event_name, :event_name), prompt: 'Choose event to add'    = submit_tag 'Add event config'  

By loading the edit page directly and clicking on the submit button it sends a PATCH request to the update action, which works perfectly:

Started PATCH "/tracking_configs/6"

But when I use the second form to add an item to the first form by rendering the HTML in a .js.erb view:

<%    tracking_event_config_block = render(      "tracking_event_config_block",      form: ActionView::Helpers::FormBuilder.new(        "tracking_config[tracking_event_configs_attributes][]",        @tracking_event_config,        self,        {}      )    )  %>  $('.event-fields').append(    '<%= j tracking_event_config_block %>'  )  

Then pressing the Save button triggers a routing error:

No route matches [POST] "/tracking_configs/6"

The strange thing is that the _method param is being sent in the correct way to the request: enter image description here

To mention that I use exactly the same forms for the #new action and it works well there.

Ajax call on a <select> in a formtastic call

Posted: 17 Jan 2017 07:04 AM PST

I need in my app to select from a list of provider a provider, and then, via ajax, I could see below a list of categories, that belongs to a specific provider. I have a form in activeadmin:

<%= semantic_form_for [:admin, @game], builder: ActiveAdmin::FormBuilder do |f| %>    <%= f.semantic_errors :state %>      <%= f.inputs do %>          <%= f.input :categorization_id, label: 'Provider', as: :select,                      collection: Provider.all.map { |provider| ["#{provider.name}", provider.id] },                      input_html: { class: (:provider_select), 'data-url': category_select_path(provider: 4) } %>          <%= f.input :categorization_id, label: 'Category',input_html: { class: ('category_dropdown') }, as: :select,                      collection: Category.all.map { |category| ["#{category.name}", category.id]}%>          ...        <% end %>    <%= f.actions %>  <% end %>  

In activeadmin controller I have:

controller do    def ajax_call        @provider = Provider.find(params[:provider])        @categories = @provider.categories        respond_to do |format|          format.json { render json: @categories }        end      end  end  

JS:

$(document).on('ready page:load', function () {      $('.select.input.optional').last().addClass('hidden_row');      $('#game_categorization_id').change(function () {      var id_value = this.value;      $('.hidden_row').removeClass('hidden_row');      $.ajax({        type: 'GET',        url: '/admin/games/category_select'        // data: id_value      })    });    });  

And the routes: match '/admin/games/category_select' => 'admin/games#ajax_call', via: :get, as: 'category_select'

I don't have an idea, how can I pass providers id from collection into url. Currently, I have there category_select_path(provider: 4), but actually it has to be smth. like this - category_select_path(provider: provider.id) In the browser, in a Network tab of devtools I can see my category_select, but there is an error: Couldn't find Game with 'id'=category_select. I can't figure out from where does it come. Any suggestions? Thanks.

<%=%> vs <%%> in Ruby [duplicate]

Posted: 17 Jan 2017 07:05 AM PST

This question already has an answer here:

I have a form in ruby html:

<%= form_for :article do |f| %>  <p>    <%= f.label :title %><br>    <%= f.text_field :title %>  </p>  <p>    <%= f.label :text %><br>    <%= f.text_area :text %>  </p>    <p>    <%= f.submit %>  </p>  <% end %>  

Attention

The last line of code:<% end %>, why it is not <%= end %>?

whats the different function with them? and if use <%= end %>, there will get this syntax error.

Rails 4, Pusher, Jquery: The conrrect way of implementing real time contextual notifications

Posted: 17 Jan 2017 07:25 AM PST

I'm currently working on a project (Rails 4 App) that requires me to implement a real time contextual notification system, witch means that depending on the active page (context), the user receives the appropriate notifications (for that page only).

I've already tried some solutions, but i'm still not sure about the correct way of doing this, considering the scalability of the project and the ease of use of the solution.

My first try was as simple as possible:

My notification Model

# == Schema Information    #    # Table name: push_notifications    #    #  id                   :integer          not null, primary key    #  notifiable_id        :integer    #  notifiable_type      :string(255)    #  seen                 :boolean    #  validated            :boolean    #  seen_date            :datetime    #  validated_date       :datetime    #  message_type         :integer    #  created_at           :datetime    #  updated_at           :datetime    #  user_to_notify_id    :integer    #  user_who_notified_id :integer    #  contexts             :string           is an Array    #  notification_type    :integer    #      class PushNotification < ActiveRecord::Base      extend Enumerize        # include ActsAsParanoid::Associations      belongs_to :notifiable, polymorphic: true      belongs_to :user_to_notify, :class_name => "User"      belongs_to :user_who_notified, :class_name => "User"          enumerize :notification_type, in: {        normal: 1,        validation: 2,      }, default: :normal          def define_notification_path(parameters = {notification: self})        self.notifiable.get_notification_path(self.notification_type,self.message_type,parameters)      end        def message(parameters = {notification: self})        notifiable.get_notification_message(self.notification_type,self.message_type,parameters).try(:capitalize)      end        def notifiable        notifiable_type.constantize.unscoped { super }      end        class << self        def of_user(user_id)          PushNotification.where(user_to_notify_id: user_id)        end      end      end  

I could've made the contexts as a separate table, but meeh, laziness :')

Notifiable model Exemple:

class User < ActiveRecord::Base      extend Enumerize        has_many :push_notifications, as: :notifiable      ...        def get_notification_path(notification_type,message_type,parameters)        ...      end        def get_notification_message(notification_type,message_type,parameters)        ...      end  

self explanatory I guess.

Exemple of the notification creation:

I used a methode that i declared in the ApplicationController:

class ApplicationController < ActionController::Base    ...    protected    def send_live_notification(notifiable, user_to_notify_id, user_who_notified_id, message_type,notification_type='normal', contexts = nil, parameters = {})      return false if user_who_notified_id == user_to_notify_id      contexts ||= []      notification = PushNotification.create(notifiable: notifiable,                                             seen: false,                                             validated: false,                                             user_to_notify_id: user_to_notify_id,                                             user_who_notified_id: user_who_notified_id,                                             message_type: message_type,                                             notification_type: notification_type,                                             contexts: contexts)        parameters = {notification: notification}        contexts.each do |c|        Pusher["#{user_to_notify_id}"].trigger("#{c}-notifications", {          object: notification.to_json,          message: notification.message(parameters),          redirect_url: notification.define_notification_path(parameters),          user_who_notified_image: notification.user_who_notified.try(:image_url)        })      end      end    end  

sloppy usage of Pusher but it worked, I sent the notifications attributes to a Pusher channel with the id of the receiving user and events matching the contexts names,

this message is received in the client connected to that channel and has an active page with one of the contexts. and using Jquery I create and insert the appropriate HTML.

The But: this solution works just fine, except that it requires a lot of maintenance work and for every new context, I have to edit every existing call of send_live_notification of the notifications that concerns the new context, and i don't have anywhere that lists all the contexts available.

My second try was aimed to fix some the problems above, witch I would like to explain but the question is long enough already. (Basically using a method that gives me the contexts of a notification and another that gives me the notifications of a context.)

So I'm hopping to get some "Best practices" or the correct way to implement a real time Contextual notifications system.

i18n pluralize dont work correct on production unicorn and nginx

Posted: 17 Jan 2017 07:40 AM PST

When I run my app using default WEBrick server, and set locale works perfectly. However, when I use Nginx and Unicorn to run my app, i18n doesnt work like it does in WEBrick.

I have following method

t('law_articles.count', count: @law_articles.total_count)  

ru.yml

law_articles:      count:        zero: 'text 1'        one: 'text 2'        few: 'text %{count} text3'        many: 'text %{count} text3'        other: 'text %{count} text4'  

On localhost are working all correct. but on production, remote server nginx + unicorn not correct. For example @law_articles.total_count return 43, but render on html every time text 1

Could anyone please teach me how to make i18n work?I'm stack all day.... Please excuse my poor English skill... Thank you in advance.

Rails content_for not rendering partial

Posted: 17 Jan 2017 07:33 AM PST

For some reason I can not render a partial inside a content_for block.

Here's the code:

/ => index.html.slim  doctype html  html lang="de"    = render "layouts/headinclude"    body      = yield      - if Rails.env.production?        - content_for :additional_headincludes do          = render "layouts/hotjar"  

For some reason the following does not include my partial once fully rendered:

  / # => _headinclude.html.slim    head      title= @title || "My Title"      link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'      - if content_for?(:additional_headincludes)        = yield :additional_headincludes  

I do not see a reason why this would not work. Any help is appreciated. When rendering the partial directly inside my headinclude-partial, it's working all fine.

Benchmarking crono scheduler in enterprise level

Posted: 17 Jan 2017 06:08 AM PST

I have been using Crono gem in some personal applications. Now I was planning to use Crono in my current organization, to schedule jobs at enterprise level.

I wanted to know if any one have already run some benchmarking tests for the performance/load/jobs that Crono can handle. If not, any suggestions how to do such an evaluation?

Redis::ConnectionError on Heroku

Posted: 17 Jan 2017 06:01 AM PST

I setup Redis on heroku and it's working fine but sometime I'm getting error in NEW RELIC.

Redis::ConnectionError > Connection reset by peer

See screenshots enter image description here

Not able to understand why this Redis lost his connection. This error comes randomly. sometime it's working and sometime i'm getting this error. I have 1 Standard 2x Dyno on heroku.

Detail Log : http://awesomescreenshot.com/01d6834i3c

Rals 5 ActionClable error description and rejected connection

Posted: 17 Jan 2017 08:08 AM PST

I made a basic chat with ActionCable authenticated with devise.

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

But when the user has an open chat and it rejects the connection (because the users have logged out), I need to show a login screen.

The problem is that on the frontend I can't get the reason for the disconnection.

How can I send reject with params, like "unauthorized"?

List sessions for a user in Rails

Posted: 17 Jan 2017 06:18 AM PST

In my Rails app I am storing sessions in the database using activerecord-session_store.

What I want to do is allow a user to view a list of all their sessions and be able to revoke any that they don't recognize (except for the one they are currently using). However I'm having a couple issues getting it to work as intended!

I have a method in my account controller called sessions:

def sessions    @sessions = Session.all  end  

1.) How can I limit the sessions returned to just the ones that belong to the user. In the sessions table, there isn't a user_id column and everything is encrypted into a data column. How can I get only the sessions for that user?

In the view I have the following:

<div class="panel">    <p>This is a list of devices that have logged into your account. Revoke any sessions that you do not recognize.</p>    <% @sessions.each do |session| %>        <li>          <dl>            <dt>IP Address</dt>            <dd>---</dd>          </dl>          <dl>            <dt>DateTime</dt>            <dd><%= session.created_at %></dd>          </dl>          <% if session != '' %>              <div class="btn-group">                <%= link_to 'Revoke', revoke_session(session), :method => 'delete' %>              </div>          <% end %>        </li>    <% end %>  </div>  

2.) How do I attach an IP address (and other data) to this session that I can then retrieve?

In the sessions controller when a user successfully logs in I do the following:

session[:user_id] = user.id

But how can I add additional data to this session? I'd want to add the request.remote_ip to it and be able to retrieve it easily. Would it be as simple as session[:ip_address] = request.remote_ip? But how would I then get back this data?

3.) How can I make sure that the revoke button doesn't appear for the current session. Is there a way to check that the session is the one currently being used.

Ruby On Rails - Make less Database Queries

Posted: 17 Jan 2017 06:29 AM PST

In my application I have a WebsiteAd model & website_ads table where I have all my websites ads that I can control from my admin.

Currently in a page I do 1 query for each ad to database and in my view as well to see if the ad is active.

In my controller:

# START - Desktop ads  def ads_desktop_tablet    @header_desktop_tablet = ad_placement('header_desktop-tablet')    @footer_desktop_tablet = ad_placement('footer_desktop-tablet')    @footer_desktop_tablet_c = ad_placement('footer_desktop-tablet_C')    @desktop_tablet_b1 = ad_placement('desktop-tablet_B1')    @desktop_tablet_b2 = ad_placement('desktop-tablet_B2')    @desktop_tablet_b3 = ad_placement('desktop-tablet_B3')    @desktop_tablet_s1 = ad_placement('desktop-tablet_S1')    @desktop_inline_banner = ad_placement('desktop_inline_banner')    @desktop_inline_video = ad_placement('desktop_inline_video')    @desktop_tablet_b2_c = ad_placement('desktop-tablet_B2_C')    @desktop_tablet_b3_c = ad_placement('desktop-tablet_B3_C')    @desktop_tablet_s1_c = ad_placement('desktop-tablet_S1_C')    @desktop_tablet_l1 = ad_placement('desktop-tablet_L1')  end  # END - Desktop ads    # START - Mobile ads  def ads_mobile    @header_mobile = ad_placement('header_mobile')    @footer_mobile = ad_placement('footer_mobile')    @mobile_b1 = ad_placement('mobile_B1')    @mobile_b2 = ad_placement('mobile_B2')    @mobile_b3 = ad_placement('mobile_B3')    @mobile_s1 = ad_placement('mobile_S1')    @mobile_inline_banner = ad_placement('mobile_inline_banner')    @mobile_b3_c = ad_placement('mobile_B3_C')  end  # END - Mobile ads  

In my helper:

def ad_placement(placement)    WebsiteAd.where(placement: placement).first  end    # I have a method/`def` for each ad like below  def ad_desk_s1_active?    if desktop_tablet_s1.status == true      desktop_tablet_s1.ad_tag.html_safe    end  end  

In my view:

= ad_desk_s1_active?  

I know this is not a good practice and right way to do. How can I make this more efficient and much less code and db queries?

Ruby Rack Heroku: No CSS styling when serving a static site

Posted: 17 Jan 2017 06:26 AM PST

I've been attempting to deploy a static site of HTML, CSS, font, and image files with Ruby Rack (https://devcenter.heroku.com/articles/static-sites-ruby). I'm running it locally and the site's HTML displays in Chrome but CSS assets don't seem to be loading and applied to the HTML. Nor do images appear.

I've been focusing on config.ru but this might not be the issue:

  use Rack::Static,    :urls => ["/images", "/fonts", "/css"],    :root => "public"      run lambda { |env|    [      200,      {        'Content-Type'  => 'text/html',        'Cache-Control' => 'public, max-age=86400'      },      File.open('public/index.html', File::RDONLY)    ]  }  

I've used both the WEBrick and Thin servers and there's almost no difference in result (Thin will serve SVGs).

My directory structure looks like this (there's a link to fees.html from within index.html but when I click on this "fees.html" link, the fees.html doesn't load - index.html is displayed instead):

- site    |- config.ru    |- Gemfile    |- Gemfile.lock    |- public      |- index.html      |- fees.html      |- css      |- fonts      |- images  

Question: Although I've used Heroku to deploy apps in the past, I'm new to deploying static sites. Should I change something in config.ru or might the issue lurk elsewhere?

EDIT I should mention that the site itself displays correctly (styling correctly applied, all assets included) when I open it in Chrome without using Ruby Rack.

EDIT 2 index.html:

<!DOCTYPE html>  <html lang="en-us">      <head>          <meta http-equiv="X-UA-Compatible" content="IE=Edge">          <meta name="viewport" content="width=device-width, initial-scale=1">          <meta charset="UTF-8">          <!-- CSS -->          <link rel="stylesheet" href="css/normalize.css">          <link rel="stylesheet" href="css/style.css">      </head>      <body>        <main>          <section class="tech" id="nextsection">            <div class="tech-row">              <div class="tech-column">                <img src="images/red_icon.svg" alt="Your Cash">                <h4>Your Cash</h4>                <p>Seed your retirement with recurring payments</p>              </div>             </div>         </section>        </main>      </body>  </html>  

Edit 3 Here's the repo with code. When I download and open locally in Chrome, it displays correctly.

How to format upload source with Google Drive REST API for Ruby / Rails?

Posted: 17 Jan 2017 05:31 AM PST

I'm writing a rails app using Google Drive REST API V3. Everything's going quite well, but I cannot seem to get uploads to Drive / Docs working fully. I think it has to do with how I'm formatting the upload source. When I test without an upload source (i.e., with only a title and some metadata) the Doc creation works fine.

I'm using Carrierwave + S3 to accept a file upload, and then trying to pass that to Drive to create a Doc in my create function on the controller. Here's the code block for Ruby from the API docs:

file_metadata = {    name: 'My Report',    mime_type: 'application/vnd.google-apps.spreadsheet'  }  file = drive_service.create_file(file_metadata,                                   fields: 'id',                                   upload_source: 'files/report.csv',                                   content_type: 'text/csv')  

I cannot find further documentation on how to handle upload_source. (Again, it works fine when I just comment that line out.) The error I get now is this:

Errno::ENOENT: No such file or directory @ rb_sysopen - path/to/file  

This happens no matter if I'm using the S3 URL or a local URL/path. So I'm thinking I'm just not dealing with the upload_source syntax properly.

I'm planning on writing up a post on this once I figure it out. Any help in the meantime would be greatly appreciated!

How can i merge multiple XMLs excluding duplicate content in rails?

Posted: 17 Jan 2017 05:19 AM PST

I have three xml files that look like this :-

<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">  <Default ContentType="application/xml" Extension="xml"/>  <Default ContentType="image/png" Extension="png"/>  <Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" PartName="/word/settings.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" PartName="/word/styles.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" PartName="/word/footer1.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" PartName="/word/fontTable.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" PartName="/word/numbering.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" PartName="/word/document.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" PartName="/word/header1.xml"/>  </Types>      <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">  <Default ContentType="application/xml" Extension="xml"/>  <Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" PartName="/word/settings.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" PartName="/word/styles.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" PartName="/word/fontTable.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" PartName="/word/numbering.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" PartName="/word/document.xml"/>  </Types>    <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">  <Default ContentType="image/jpeg" Extension="jpg"/>  <Default ContentType="application/xml" Extension="xml"/>  <Default ContentType="image/png" Extension="png"/>  <Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" PartName="/word/settings.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" PartName="/word/styles.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" PartName="/word/fontTable.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" PartName="/word/numbering.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" PartName="/word/document.xml"/>  </Types>  

I'd like to merge them without any duplication of content, so that the end result looks something like this :-

<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">  <Default ContentType="application/xml" Extension="xml"/>  <Default ContentType="image/png" Extension="png"/>  <Default ContentType="image/jpeg" Extension="jpg"/>  <Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" PartName="/word/settings.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" PartName="/word/styles.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" PartName="/word/footer1.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" PartName="/word/fontTable.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" PartName="/word/numbering.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" PartName="/word/document.xml"/>  <Override ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" PartName="/word/header1.xml"/>  </Types>  

I am using Nokogiri, but till now I could only find how to add new nodes to an xml. But I'd like to check for duplication as well. Any ideas on how to do this.

HTTParty get request using Basic Auth

Posted: 17 Jan 2017 05:02 AM PST

I am trying to make get request to this address https://unicom24.ru/api/partners/requests/v1/locality/

I am using httparty gem. I need to use basic http Auth. I got my auth key and do request like this:

headers = {'Authorization' => 'Basic bMyAuthKeydv4K'}  HTTParty.get(    "https://unicom24.ru/api/partners/requests/v1/locality/",     :headers => headers  )  

And I get a reply:

@response=#<Net::HTTPUnauthorized 401 Unauthorized readbody=true>  

unallowable email or password. What do I do?

Predefine Model instance in Rails(with association)

Posted: 17 Jan 2017 05:43 AM PST

I need some predefined instance of ActiveRecord model(with an association) to use it in report(some pdf file) generation which my application perform. So the question is: how should I do this and where should I put it(constant in model, seeds etc.)?

Having probleman with ActionController::UrlGenerationError on RSPEC

Posted: 17 Jan 2017 04:37 AM PST

Im writing some tests for my controller, but im getting the error below when i'm running rspec ./spec/controllers, when i just run the spec direct in the file i'm getting everything green.

1) VersionOne::UsersController GET #actives should return all actives   Failure/Error: get :actives     ActionController::UrlGenerationError:     No route matches {:action=>"actives", :controller=>"version_one/users"}   # ./spec/controllers/version_one/users_controller_spec.rb:13:in `block (3 levels) in <top (required)>'    2) VersionOne::UsersController GET #archived should return all archives   Failure/Error: get :archives     ActionController::UrlGenerationError:     No route matches {:action=>"archives", :controller=>"version_one/users"}   # ./spec/controllers/version_one/users_controller_spec.rb:23:in `block (3 levels) in <top (required)>'    3) VersionOne::UsersController POST #create should create a new collaborator with success   Failure/Error: post :create, params: params  

This is my controller

class UsersController < ApiControler    def actives      users = User.actives      render json: users    end      def archives      users = User.archiveds      render json: users   end      def create      user = User.build(user_params)      render json: user    end  end  

This are my routes

  scope 'api' do      scope 'v1', module: 'version_one' do        resources 'users' do          collection do            get 'actives'            get 'archives'          end            member do            match 'active'            match 'archive'          end        end      end    end  

This are my tests

RSpec.describe VersionOne::UsersController, type: :controller do    before(:all) do      7.times { Collaborator.build(attributes_for(:user)) }      8.times { Admin.build(attributes_for(:user)) }      5.times { Collaborator.build(attributes_for(:user)).archived! }    end      describe "GET #actives" do      it "should return all actives" do      get :actives      body = JSON.parse(response.body)      expect(response).to have_http_status(:success)      expect(body["pagination"]["per_page"]).to eq(20)      expect(body["pagination"]["total_objects"]).to eq(15)    end   end     describe "GET #archived" do     it "should return all archives" do       get :archives       body = JSON.parse(response.body)       expect(response).to have_http_status(:success)       expect(body["pagination"]["per_page"]).to eq(20)       expect(body["pagination"]["total_objects"]).to eq(5)     end   end     describe "POST #create" do     it "should create a new collaborator with success" do       params = { kind: "Collaborator", user: { name: "User", email: "user@email.net", password: "123456", cpf: "36156291830" } }       post :create, params: params       body = JSON.parse(response.body)       expect(response).to have_http_status(:success)       expect(body).to include(         "name" => "User",         "cpf" => "36156291830",         "email" => "user@email.net",        )      end    end  end  

this is my .rspec

--color  --format documentation  --require rails_helper  

this is my rails_helper

ENV['RAILS_ENV'] ||= 'test'    require File.expand_path('../../config/environment', __FILE__)    abort("The Rails environment is running in production mode!") if Rails.env.production?    require 'spec_helper'  require 'rspec/rails'  require 'shoulda-matchers'  require 'rack/test'  require 'faker'  require 'rake'    ActiveRecord::Migration.maintain_test_schema!    RSpec.configure do |config|    config.include FactoryGirl::Syntax::Methods    config.include Shoulda::Matchers::ActiveModel, type: :model    config.include Shoulda::Matchers::ActiveRecord, type: :model    config.fixture_path = "#{::Rails.root}/spec/factories"    config.before(:suite) do      DatabaseCleaner.strategy = :truncation      DatabaseCleaner.clean_with(:truncation)    end      config.use_transactional_fixtures = false    config.infer_spec_type_from_file_location!    config.filter_rails_from_backtrace!    end  

am'i forgetting something?

Rails validations with enum

Posted: 17 Jan 2017 04:43 AM PST

I have an enum in my Box model

enum box_type: [:wooden, :plastic, :metal, :paper]  

and I want the box_type attribute of my Box model to be only one of those, so:

validates :box_type, inclusion: {in: box_types.keys }  

It seems that it should be working flawlessly, but what I also have is a default value when creating my Box model, set like this:

class CreateBoxes < ActiveRecord::Migration[5.0]    def change      create_table :boxes do |t|          ...          t.string  :box_type,      null: false, default: "paper"          ...        t.timestamps      end    end  end  

and when I try to create a record in my console I get a rollback. Error:

@messages={:box_type=>["is not included in the list"]}, @details={:box_type=>[{:error=>:inclusion, :value=>nil}]}  

Questions:

  1. What am I doing wrong?
  2. Is there any better way to only allow particular values inside my database column?

Nested form to route to proper controller action

Posted: 17 Jan 2017 04:41 AM PST

The routes define

  resources :interruptions do      collection do        post :pause        post :restart      end    end  

However, within an intervento_controller show action, where @interruption = Interruption.new is declared, a form to create a related record

<%= form_for @interruption, url: pause_interruptions_path do |f| %>    <%= f.hidden_field :intervento_id, value: @intervento.id %>    <%= submit_tag "Pausa", name: 'pausa_intervento' %>  <% end %>            

rails is routing to the intervento action, not the one stated in the form_for url declaration.

Started PATCH "/interventos/32" for ::1 at 2017-01-17 13:04:49 +0100   Processing by InterventosController#update as HTML    Parameters: {"utf8"=>"✓", [...] "interruption"=>{"intervento_id"=>"32"}, "pausa_intervento"=>"Pausa", "id"=>"32"}  

The model Intervento does allow accepts_nested_attributes_for :interruptions, however I expected this not be necessary as the form declares the action to be routed to. Also, only one record is being created or edited at a time.

How can this be achieved?

Ruby: Smiley to utf-8 encoding

Posted: 17 Jan 2017 06:56 AM PST

How can I convert this

string = "ok test body 😁😁😁\r\n-- \r\n test"  

Into this

"ok test body \\ud83d\\ude01\\ud83d\\ude01\\ud83d\\ude01\r\n-- \r\n test"  

I have tried this

string.encode('utf-16be','utf-8')  

which convert it into this form

#"ok test body \u{1F601} \u{1F601}\u{1F601}\r\n-- \r\n test"  

I think i need regular expression to solve this. Can anyone tell me how to do that. Thanks

Error installing Nginx with native Passenger module on CentOS 5

Posted: 17 Jan 2017 07:08 AM PST

I want to deploy a rails app and I'm following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-deploy-rails-apps-using-passenger-with-nginx-on-centos-6-5

However, when I run the passenger-install-nginx-modulecommand it fails to compile. The output is as follows:

Compiling Passenger support files...  # env NOEXEC_DISABLE=1 /usr/local/bin/ruby /usr/local/bin/rake nginx:clean nginx RELEASE=yes  rm -rf buildout/cache  rm -rf buildout/common/libboost_oxt.a buildout/common/libboost_oxt  rm -f buildout/common/libpassenger_common/Logging.o buildout/common/libpassenger_common/Exceptions.o buildout/common/libpassenger_common/Utils/SystemTime.o buildout/common/libpassenger_common/Utils/StrIntUtils.o buildout/common/libpassenger_common/Utils/StrIntUtilsNoStrictAliasing.o buildout/common/libpassenger_common/Utils/IOUtils.o buildout/common/libpassenger_common/Utils.o  rm -f buildout/common/libpassenger_common/Crypto.o buildout/common/libpassenger_common/Utils/CachedFileStat.o buildout/common/libpassenger_common/Utils/LargeFiles.o buildout/common/libpassenger_common/WatchdogLauncher.o buildout/common/libpassenger_common/MemoryKit/mbuf.o buildout/common/libpassenger_common/MemoryKit/palloc.o buildout/common/libpassenger_common/ServerKit/http_parser.o buildout/common/libpassenger_common/ServerKit/Implementation.o buildout/common/libpassenger_common/DataStructures/LString.o buildout/common/libpassenger_common/Utils/Hasher.o buildout/common/libpassenger_common/AppTypes.o  rm -f buildout/common/libpassenger_common/jsoncpp.o  rm -f buildout/common/libpassenger_common/vendor-modified/modp_b64.o buildout/common/libpassenger_common/vendor-modified/modp_b64_strict_aliasing.o  rm -f buildout/common/libpassenger_common/UnionStationFilterSupport.o  rm -rf buildout/common/libpassenger_common  rm -rf buildout/support-binaries/  rm -rf buildout/nginx_dynamic/libboost_oxt.a buildout/nginx_dynamic/libboost_oxt  rm -f buildout/nginx_dynamic/module_libpassenger_common/Logging.o buildout/nginx_dynamic/module_libpassenger_common/Exceptions.o buildout/nginx_dynamic/module_libpassenger_common/Utils/SystemTime.o buildout/nginx_dynamic/module_libpassenger_common/Utils/StrIntUtils.o buildout/nginx_dynamic/module_libpassenger_common/Utils/StrIntUtilsNoStrictAliasing.o buildout/nginx_dynamic/module_libpassenger_common/Utils/IOUtils.o buildout/nginx_dynamic/module_libpassenger_common/Utils.o  rm -f buildout/nginx_dynamic/module_libpassenger_common/Crypto.o buildout/nginx_dynamic/module_libpassenger_common/Utils/CachedFileStat.o buildout/nginx_dynamic/module_libpassenger_common/Utils/LargeFiles.o buildout/nginx_dynamic/module_libpassenger_common/WatchdogLauncher.o buildout/nginx_dynamic/module_libpassenger_common/MemoryKit/mbuf.o buildout/nginx_dynamic/module_libpassenger_common/MemoryKit/palloc.o buildout/nginx_dynamic/module_libpassenger_common/ServerKit/http_parser.o buildout/nginx_dynamic/module_libpassenger_common/ServerKit/Implementation.o buildout/nginx_dynamic/module_libpassenger_common/DataStructures/LString.o buildout/nginx_dynamic/module_libpassenger_common/Utils/Hasher.o buildout/nginx_dynamic/module_libpassenger_common/AppTypes.o  rm -f buildout/nginx_dynamic/module_libpassenger_common/jsoncpp.o  rm -f buildout/nginx_dynamic/module_libpassenger_common/vendor-modified/modp_b64.o buildout/nginx_dynamic/module_libpassenger_common/vendor-modified/modp_b64_strict_aliasing.o  rm -f buildout/nginx_dynamic/module_libpassenger_common/UnionStationFilterSupport.o  rm -rf buildout/nginx_dynamic/module_libpassenger_common  mkdir -p buildout/support-binaries  c++ -o buildout/support-binaries/AgentMain.o  -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="<ext/hash_map>" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="<ext/hash_fun.h>" -c src/agent/AgentMain.cpp  c++ -o buildout/support-binaries/AgentBase.o  -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="<ext/hash_map>" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="<ext/hash_fun.h>" -c src/agent/Shared/Base.cpp  c++ -o buildout/support-binaries/WatchdogMain.o  -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="<ext/hash_map>" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="<ext/hash_fun.h>" -c src/agent/Watchdog/WatchdogMain.cpp  src/cxx_supportlib/Utils/JsonUtils.h: In function 'Json::Value Passenger::byteSpeedToJson(double, const std::string&)':  src/cxx_supportlib/Utils/JsonUtils.h:327: warning: passing 'double' for argument 1 to 'Json::Value Passenger::byteSizeToJson(size_t)'  src/cxx_supportlib/Utils/JsonUtils.h:329: warning: passing 'double' for argument 1 to 'Json::Value Passenger::signedByteSizeToJson(long long int)'  src/cxx_supportlib/Utils/JsonUtils.h: In function 'Json::Value Passenger::byteSpeedToJson(double, double, const std::string&)':  src/cxx_supportlib/Utils/JsonUtils.h:341: warning: passing 'double' for argument 1 to 'Json::Value Passenger::byteSizeToJson(size_t)'  src/cxx_supportlib/Utils/JsonUtils.h:343: warning: passing 'double' for argument 1 to 'Json::Value Passenger::signedByteSizeToJson(long long int)'  src/cxx_supportlib/ServerKit/HeaderTable.h: In member function 'void Passenger::ServerKit::HeaderTable::repopulate(unsigned int)':  src/cxx_supportlib/ServerKit/HeaderTable.h:128: warning: comparison between signed and unsigned integer expressions  src/cxx_supportlib/Integrations/LibevJsonUtils.h: In function 'Json::Value Passenger::evTimeToJson(ev_tstamp, ev_tstamp, long long unsigned int)':  src/cxx_supportlib/Integrations/LibevJsonUtils.h:65: warning: converting to 'long long unsigned int' from 'ev_tstamp'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:82: warning: passing 'ev_tstamp' for argument 1 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:82: warning: passing 'ev_tstamp' for argument 2 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:84: warning: passing 'ev_tstamp' for argument 1 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:84: warning: passing 'ev_tstamp' for argument 2 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  c++ -o buildout/support-binaries/CoreMain.o  -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="<ext/hash_map>" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="<ext/hash_fun.h>" -c src/agent/Core/CoreMain.cpp  src/cxx_supportlib/Utils/JsonUtils.h: In function 'Json::Value Passenger::byteSpeedToJson(double, const std::string&)':  src/cxx_supportlib/Utils/JsonUtils.h:327: warning: passing 'double' for argument 1 to 'Json::Value Passenger::byteSizeToJson(size_t)'  src/cxx_supportlib/Utils/JsonUtils.h:329: warning: passing 'double' for argument 1 to 'Json::Value Passenger::signedByteSizeToJson(long long int)'  src/cxx_supportlib/Utils/JsonUtils.h: In function 'Json::Value Passenger::byteSpeedToJson(double, double, const std::string&)':  src/cxx_supportlib/Utils/JsonUtils.h:341: warning: passing 'double' for argument 1 to 'Json::Value Passenger::byteSizeToJson(size_t)'  src/cxx_supportlib/Utils/JsonUtils.h:343: warning: passing 'double' for argument 1 to 'Json::Value Passenger::signedByteSizeToJson(long long int)'  src/cxx_supportlib/ServerKit/HeaderTable.h: In member function 'void Passenger::ServerKit::HeaderTable::repopulate(unsigned int)':  src/cxx_supportlib/ServerKit/HeaderTable.h:128: warning: comparison between signed and unsigned integer expressions  src/cxx_supportlib/Integrations/LibevJsonUtils.h: In function 'Json::Value Passenger::evTimeToJson(ev_tstamp, ev_tstamp, long long unsigned int)':  src/cxx_supportlib/Integrations/LibevJsonUtils.h:65: warning: converting to 'long long unsigned int' from 'ev_tstamp'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:82: warning: passing 'ev_tstamp' for argument 1 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:82: warning: passing 'ev_tstamp' for argument 2 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:84: warning: passing 'ev_tstamp' for argument 1 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  src/cxx_supportlib/Integrations/LibevJsonUtils.h:84: warning: passing 'ev_tstamp' for argument 2 to 'std::string Passenger::distanceOfTimeInWords(time_t, time_t)'  src/agent/Core/SecurityUpdateChecker.h: In member function 'void Passenger::SecurityUpdateChecker::logUpdateFailCurl(CURLcode)':  src/agent/Core/SecurityUpdateChecker.h:113: error: 'CURLE_PEER_FAILED_VERIFICATION' was not declared in this scope  src/agent/Core/SecurityUpdateChecker.h:119: error: 'CURLE_SSL_CACERT_BADFILE' was not declared in this scope  src/cxx_supportlib/DataStructures/StringKeyTable.h: In member function 'void Passenger::StringKeyTable<T, MoveSupport>::repopulate(unsigned int) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, MoveSupport = Passenger::SKT_DisableMoveSupport]':  src/cxx_supportlib/DataStructures/StringKeyTable.h:265:   instantiated from 'void Passenger::StringKeyTable<T, MoveSupport>::realInsert(const Passenger::HashedStaticString&, ValueType, bool) [with ValueType = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, LocalMoveSupport = Passenger::SKT_DisableMoveSupport, T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, MoveSupport = Passenger::SKT_DisableMoveSupport]'  src/cxx_supportlib/DataStructures/StringKeyTable.h:434:   instantiated from 'void Passenger::StringKeyTable<T, MoveSupport>::insert(const Passenger::HashedStaticString&, const T&, bool) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, MoveSupport = Passenger::SKT_DisableMoveSupport]'  src/agent/Shared/ApiServerUtils.h:938:   instantiated from 'void Passenger::apiServerProcessReinheritLogs(Server*, Client*, Request*, const Passenger::StaticString&, const Passenger::StaticString&) [with Server = Passenger::Core::ApiServer::ApiServer, Client = Passenger::ServerKit::HttpClient<Passenger::Core::ApiServer::Request>, Request = Passenger::Core::ApiServer::Request]'  src/agent/Core/ApiServer.h:129:   instantiated from here  src/cxx_supportlib/DataStructures/StringKeyTable.h:178: warning: comparison between signed and unsigned integer expressions  src/cxx_supportlib/DataStructures/StringKeyTable.h: In member function 'uint32_t Passenger::StringKeyTable<T, MoveSupport>::appendToStorage(const Passenger::StaticString&) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, MoveSupport = Passenger::SKT_DisableMoveSupport]':  src/cxx_supportlib/DataStructures/StringKeyTable.h:269:   instantiated from 'void Passenger::StringKeyTable<T, MoveSupport>::realInsert(const Passenger::HashedStaticString&, ValueType, bool) [with ValueType = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, LocalMoveSupport = Passenger::SKT_DisableMoveSupport, T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, MoveSupport = Passenger::SKT_DisableMoveSupport]'  src/cxx_supportlib/DataStructures/StringKeyTable.h:434:   instantiated from 'void Passenger::StringKeyTable<T, MoveSupport>::insert(const Passenger::HashedStaticString&, const T&, bool) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, MoveSupport = Passenger::SKT_DisableMoveSupport]'  src/agent/Shared/ApiServerUtils.h:938:   instantiated from 'void Passenger::apiServerProcessReinheritLogs(Server*, Client*, Request*, const Passenger::StaticString&, const Passenger::StaticString&) [with Server = Passenger::Core::ApiServer::ApiServer, Client = Passenger::ServerKit::HttpClient<Passenger::Core::ApiServer::Request>, Request = Passenger::Core::ApiServer::Request]'  src/agent/Core/ApiServer.h:129:   instantiated from here  src/cxx_supportlib/DataStructures/StringKeyTable.h:157: warning: converting to 'unsigned int' from 'double'  rake aborted!  Command failed with status (1): [c++ -o buildout/support-binaries/CoreMain.o  -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="<ext/hash_map>" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="<ext/hash_fun.h>" -c src/agent/Core/CoreMain.cpp]    Tasks: TOP => nginx => nginx_without_native_support => buildout/support-binaries/PassengerAgent => buildout/support-binaries/CoreMain.o  (See full trace by running task with --trace)  --------------------------------------------    It looks like something went wrong    Please read our documentation for troubleshooting tips:       https://www.phusionpassenger.com/library/install/nginx/     https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/    If that doesn't help, please use our support facilities. We'll do our best to help you.       https://www.phusionpassenger.com/documentation_and_support  

Please help, I checked the suggested links and the web for solutions to solve the problem but nothing works.

Passenger version installed: Phusion Passenger 5.1.1

No comments:

Post a Comment