I've installed the travis gem
gem install travis
Installed successful, but travis login is not available from console (Ubuntu):
travis login
-bash: /usr/bin/travis: No such file or directory
I've installed the travis gem
gem install travis
Installed successful, but travis login is not available from console (Ubuntu):
travis login
-bash: /usr/bin/travis: No such file or directory
Framework: Rails 3/ Jruby with Mailboxer gem.
I want to create a Facebook style inbox page that allows a user to scroll through their Inbox, Sent Items and Trash, whilst keeping the selected conversation displayed on the right hand side of the page (like Facebook's implementation of the desktop inbox)
The action of clicking the conversation title should render that entire conversation to the right side of the page, avoiding the need of dedicating an entire page to one conversation within the web browser. This is so (in a later version) I can implement an AJAX call that will only refresh the conversation part of the page, whilst allowing the user to keep an eye on their conversation list.
My problem is, I'm completely stumped as to how this would be implemented, without the routing error No route matches [GET] "/conversations/20/show_conversation" that I'm currently getting. I'm fairly new to Ruby on Rails, so the whole routing side of things is a bit confusing.
My question how do I display all my conversations, as well as the transcript of one selected conversation (at any given time) on the same page. Preferably, I would like to avoid the use of Javascript/ jQuery and stick to the Ruby on Rails implementation, if possible.
Here's a screenshot of my "messages" page, where "Conversation.." (on the right) should display the transcript of the conversation I had with the target user.
My controller code for the current page:
class ConversationsController < ApplicationController
before_filter :authenticate_user!
before_filter :get_mailbox
before_filter :get_conversation, except: [:index]
before_filter :get_box, only: [:index]
before_filter :get_conversation, except: [:index, :empty_trash]
def index
@conversations = @mailbox.inbox.paginate(page: params[:page], per_page: 10)
@inbox = @mailbox.inbox.paginate(page: params[:page], per_page: 10)
@trash = @mailbox.trash.paginate(page: params[:page], per_page: 10)
@sent = @mailbox.sentbox.paginate(page: params[:page], per_page: 10)
end
def show_conversation
@conversation
redirect_to conversations_path
end
[...]
private
def get_mailbox
@mailbox ||= current_user.mailbox
end
def get_conversation
@conversation ||= @mailbox.conversations.find(params[:id])
end
def get_box
if params[:box].blank? or !["inbox","sent","trash"].include?(params[:box])
params[:box] = 'inbox'
end
@box = params[:box]
end
end
My corresponding views: index.html.erb
<% page_header "Your Conversations" %>
<p><%= link_to 'Start conversation', new_message_path, class: 'btn btn-lg btn-primary' %>
<%= link_to 'Empty trash', empty_trash_conversations_path, class: 'btn btn-danger',
method: :delete, data: {confirm: 'Are you sure?'} %></p>
<!-- tab things, they're awesome -->
<div class="left_col">
<div class="col-sm-3">
<ul class="nav nav-pills">
<%= mailbox_section 'inbox', @box %>
<%= mailbox_section 'sent', @box %>
<%= mailbox_section 'trash', @box %>
</ul>
</div>
<!-- this working part isn't in the tutorial -->
<% if @box == 'trash' %>
<%= render partial: 'conversations/conversation', collection: @trash %>
<% elsif @box == 'inbox' %>
<%= render partial: 'conversations/conversation', collection: @inbox %>
<% elsif @box == 'sent' %>
<%= render partial: 'conversations/conversation', collection: @sent %>
<% end %>
<%= will_paginate %>
</div>
<div class="right_col">
<p><small>Conversation...</small></p>
<%= @conversation %> <!-- should I have a partial or something? -->
</div>
_conversation.html.erb partial where the link to show_conversation is
<%= link_to conversation.subject, show_conversation_conversation_path(conversation) %>
<div class="btn-group-vertical pull-right">
<% if conversation.is_trashed?(current_user) %>
<%= link_to 'Restore', restore_conversation_path(conversation),
class: 'btn btn-xs btn-info', method: :post %>
<% else %>
<%= link_to 'Move to trash', conversation_path(conversation),
class: 'btn btn-xs btn-danger', method: :delete,
data: {confirm: 'Are you sure?'} %>
<% if conversation.is_unread?(current_user) %>
<%= link_to 'Mark as read', mark_as_read_conversation_path(conversation),
class: 'btn btn-xs btn-info', method: :post %>
<% end %>
<% end %>
</div>
<p><%= render 'conversations/participants', conversation: conversation %></p>
<p><%= conversation.last_message.body %>
<small>(<span class="text-muted">
<%= conversation.last_message.created_at.strftime("%-d %B %Y, %H:%M:%S") %>
</span>)</small></p>
And finally, my routes.rb
resources :conversations, only: [:index, :show, :destroy] do
member do
post :reply, :restore, :mark_as_read, :show_conversation
end
collection do
delete :empty_trash
end
end
resources :messages, only: [:new, :create]
root :to => 'conversations#index'
I do have a working conversation partial that builds the conversation on a separate page. It works fine, but I haven't included it because I want to move away from having a separate page to view the conversation. Any help on this would be greatly appreciated!
Thanks,
I am using the ruby-zbar gem in a rails app to scan barcodes from jpgs. I installed the zbar library using homebrew on my local machine and everything works fine. However, when deploying to Heroku I consistently get errors such as the following:
remote: LoadError: Didn't find libzbar on your system
remote: Please install zbar (http://ift.tt/refsyg) or set ZBAR_LIB if it's in a weird place
remote: FFI::Library::ffi_lib() failed with error: library names list must not be empty
I've tried following the advice from this Stack Overflow post (Heroku Zbar Didn't find libzbar on your system (LoadError)), namely to set the ZBAR_LIB ENV variable to /app/vendor/lib/libzbar.so, or failing that to run heroku bash and try to find a file named libzbar.so and point ZBAR_LIB to its path.
However, I can't seem to find the heroku buildpack referenced in the original Stack Overflow post (the link to http://ift.tt/1mpaR2J goes to a 404 page), so I can't replicate the solution outlined there.
I have tried all of the following buildpacks:
http://ift.tt/1ImOq5Q
http://ift.tt/1KO1BT3
http://ift.tt/1ImOsdY
During the build process I can see hopeful messages like this:
remote: -----> Multipack app detected
remote: -----> Fetching custom git buildpack... done
remote: -----> ZBAR app detected
remote: -----> Downloading and installing ZBAR
remote: -----> Configuring ZBAR
remote: -----> Make!
remote: -----> Make install !!!
remote: -----> Writing profile script
remote: -----> Fetching custom git buildpack... done
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.1
But setting ZBAR_LIB to /app/vendor/lib/libzbar.so gives me some version of this error:
remote: LoadError: Didn't find libzbar on your system
remote: Please install zbar (http://ift.tt/refsyg) or set ZBAR_LIB if it's in a weird place
remote: FFI::Library::ffi_lib() failed with error: Could not open library '/app/vendor/lib/libzbar.so': /app/vendor/lib/libzbar.so: cannot open shared object file: No such file or directory
And trying to find libzbar.so on heroku run bash has not been successful for me -- I can see many files that are similar in name (even a libzbar.rc) but none that fits the bill.
~ $ find / -name '*libzbar*'
find: `/var/lib/polkit-1': Permission denied
/app/vendor/zbar/plugin/.deps/plugin_libzbarplugin_la-plugin.Plo
/app/vendor/zbar/qt/.deps/qt_libzbarqt_la-QZBar.Plo
/app/vendor/zbar/qt/.deps/qt_libzbarqt_la-QZBarThread.Plo
/app/vendor/zbar/qt/.deps/qt_libzbarqt_la-moc_QZBarThread.Plo
/app/vendor/zbar/qt/.deps/qt_libzbarqt_la-moc_QZBar.Plo
/app/vendor/zbar/gtk/.deps/gtk_libzbargtk_la-zbargtk.Plo
/app/vendor/zbar/gtk/.deps/gtk_libzbargtk_la-zbarmarshal.Plo
/app/vendor/zbar/zbar/zbar_libzbar_la-symbol.lo
/app/vendor/zbar/zbar/zbar_libzbar_la-video.o
/app/vendor/zbar/zbar/zbar_libzbar_la-error.lo
/app/vendor/zbar/zbar/processor/zbar_libzbar_la-lock.lo
/app/vendor/zbar/zbar/processor/.libs/zbar_libzbar_la-lock.o
/app/vendor/zbar/zbar/processor/zbar_libzbar_la-lock.o
/app/vendor/zbar/zbar/processor/.deps/zbar_libzbar_la-null.Plo
/app/vendor/zbar/zbar/processor/.deps/zbar_libzbar_la-x.Plo
/app/vendor/zbar/zbar/processor/.deps/zbar_libzbar_la-posix.Plo
/app/vendor/zbar/zbar/processor/.deps/zbar_libzbar_la-lock.Plo
/app/vendor/zbar/zbar/processor/.deps/zbar_libzbar_la-win.Plo
/app/vendor/zbar/zbar/zbar_libzbar_la-config.o
/app/vendor/zbar/zbar/zbar_libzbar_la-processor.o
/app/vendor/zbar/zbar/zbar_libzbar_la-refcnt.lo
/app/vendor/zbar/zbar/zbar_libzbar_la-convert.o
/app/vendor/zbar/zbar/zbar_libzbar_la-video.lo
/app/vendor/zbar/zbar/zbar_libzbar_la-window.o
/app/vendor/zbar/zbar/video/.deps/zbar_libzbar_la-null.Plo
/app/vendor/zbar/zbar/video/.deps/zbar_libzbar_la-v4l1.Plo
/app/vendor/zbar/zbar/video/.deps/zbar_libzbar_la-v4l2.Plo
/app/vendor/zbar/zbar/video/.deps/zbar_libzbar_la-vfw.Plo
/app/vendor/zbar/zbar/zbar_libzbar_la-processor.lo
/app/vendor/zbar/zbar/zbar_libzbar_la-image.lo
/app/vendor/zbar/zbar/zbar_libzbar_la-refcnt.o
/app/vendor/zbar/zbar/zbar_libzbar_la-error.o
/app/vendor/zbar/zbar/qrcode/.deps/zbar_libzbar_la-qrdectxt.Plo
/app/vendor/zbar/zbar/qrcode/.deps/zbar_libzbar_la-binarize.Plo
/app/vendor/zbar/zbar/qrcode/.deps/zbar_libzbar_la-isaac.Plo
/app/vendor/zbar/zbar/qrcode/.deps/zbar_libzbar_la-rs.Plo
/app/vendor/zbar/zbar/qrcode/.deps/zbar_libzbar_la-qrdec.Plo
/app/vendor/zbar/zbar/qrcode/.deps/zbar_libzbar_la-bch15_5.Plo
/app/vendor/zbar/zbar/qrcode/.deps/zbar_libzbar_la-util.Plo
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-video.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-config.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-processor.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-convert.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-window.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-refcnt.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-error.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-img_scanner.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-image.o
/app/vendor/zbar/zbar/.libs/zbar_libzbar_la-symbol.o
/app/vendor/zbar/zbar/zbar_libzbar_la-img_scanner.o
/app/vendor/zbar/zbar/zbar_libzbar_la-image.o
/app/vendor/zbar/zbar/window/.deps/zbar_libzbar_la-null.Plo
/app/vendor/zbar/zbar/window/.deps/zbar_libzbar_la-dib.Plo
/app/vendor/zbar/zbar/window/.deps/zbar_libzbar_la-xv.Plo
/app/vendor/zbar/zbar/window/.deps/zbar_libzbar_la-x.Plo
/app/vendor/zbar/zbar/window/.deps/zbar_libzbar_la-ximage.Plo
/app/vendor/zbar/zbar/window/.deps/zbar_libzbar_la-win.Plo
/app/vendor/zbar/zbar/zbar_libzbar_la-img_scanner.lo
/app/vendor/zbar/zbar/libzbar.rc
/app/vendor/zbar/zbar/zbar_libzbar_la-symbol.o
/app/vendor/zbar/zbar/zbar_libzbar_la-config.lo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-decoder.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-config.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-convert.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-processor.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-symbol.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-scanner.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-error.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-jpeg.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-video.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-window.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-refcnt.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-svg.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-img_scanner.Plo
/app/vendor/zbar/zbar/.deps/zbar_libzbar_la-image.Plo
/app/vendor/zbar/zbar/zbar_libzbar_la-window.lo
/app/vendor/zbar/zbar/decoder/.deps/zbar_libzbar_la-code39.Plo
/app/vendor/zbar/zbar/decoder/.deps/zbar_libzbar_la-pdf417.Plo
/app/vendor/zbar/zbar/decoder/.deps/zbar_libzbar_la-qr_finder.Plo
/app/vendor/zbar/zbar/decoder/.deps/zbar_libzbar_la-i25.Plo
/app/vendor/zbar/zbar/decoder/.deps/zbar_libzbar_la-ean.Plo
/app/vendor/zbar/zbar/decoder/.deps/zbar_libzbar_la-code128.Plo
/app/vendor/zbar/zbar/zbar_libzbar_la-convert.lo
Has anyone had success getting zbar to run on heroku? If so, what buildpack did you use? I would be thrilled to learn how to make this work.
ps aux | grep elasticsearchcd app/currect && RAILS_ENV=production bin/rails cUser.import
Output:
Scoped order and limit are ignored, it's forced to be batch order and batch size
User Load (0.4ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 10
Faraday::ConnectionFailed: connection refused: localhost:9200
Elasticsearch stopped and import doesn't work, why ?
I am using Ubuntu 14, Puma server, SQLite database. Does it matter?
Additional notes:
http://ift.tt/1P3OOuv - gemfile.lock from project
http://ift.tt/1IVORti - elasticsearch config
http://ift.tt/1P3OOux - elasticsearch log
Before User.import
ps aux | grep elasticsearch
shows elasticsearch process
After User.import ps aux | grep elasticsearch doesn't show process
How to check if elasticsearch uses 9200 port ?
I'd like to know the definition of method from a huge github repository (say from example i want to see the definition of super method in this github repository).
Are there any tools to do it quickly?
I'm new in Ruby (and in developing too) and I would like to get the response from another url (my url) in the get method.
i'm using rest-client gem.
I have tried this code:
class UsersController < ApplicationController require 'rest-client' def index
RestClient::Request.execute( method: :get, url: 'https://my-url')
end
end
but when I open http://localhost:3000/users I get a blank page
Thanks in advance,
Joel
I'm wanting to create a pair of classes. The second of the pair sub-classes the first, is nested within the first, and only has the addition of being an Enumerator. Like so:
MyClass # this is the parent class
MyClass::Enumerator # it has an Enumerator which sub-classes MyClass
Further to this, when sub-classing MyClass, the subclass should get its own iterator which is also nested within it. Like so:
MySubClass = Class.new(MyClass) # This class sub-classes MyClass
MySubClass::Enumerator # It has an Enumerator which sub-classes MySubClass
I've actually created the code and it works, but I'm wondering if there is a better way or an existing design pattern to achieve this. The code I've written to make this work is the following:
module EnumerableCompanionClass
extend ActiveSupport::Concern
# this ensures the parent class gets it's companion class
included { create_enumerable_class }
module ClassMethods
# this ensures an descendants get their companion class
def inherited(sub)
# need to make sure this doesn't get called for the companion class.
# at this point it's still an anonymous class
# this is to stop infinite recursion
unless sub.name.blank? || sub < Enumerable
sub.create_enumerable_class
end
end
def create_enumerable_class
# only create the companion class once
@enumerable_class ||=
# create the companion class as a subclass of the current class
# but only if self is a class (not a module) and is not the companion class
if self.is_a?(Class) && !(self < Enumerable)
enumerable_class = Class.new(self) do
include ::Enumerable
# my custom each method
def each(&block); end
end
# define a constant for the companion class
const_set('Enumerable', enumerable_class)
end
end
end
end
And this is the code to check that it works as expected:
class A
include EnumerableCompanionClass
def test1; 'this should work!'; end
end
A::Enumerable.parent == A # true
A::Enumerable.new.test1 # 'this should work!'
class B < A
def test2; 'this should also work'; end
end
B::Enumerable.parent == B # true
B::Enumerable.new.test1 # 'this should work!'
B::Enumerable.new.test2 # 'this should also work'
class C < B
def test3; 'this should triple work'; end
end
C::Enumerable.parent == C # true
C::Enumerable.new.test1 # 'this should work!'
C::Enumerable.new.test2 # 'this should also work'
C::Enumerable.new.test3 # 'this should triple work'
So as you can see from the output, it all works as expected.
But it's messy and not very intuitive. For starters, the included method is only there for the parent. Likewise, the inherited method is only there for the sub-classes. The checks for anonymous classes and unnamed classes are there to prevent infinite recursion (we don't want the Enumerator classes to have it's own Enumerator).
I'm happy that it works but I'm sure there has to be a better way. I've tried other methods and this is the only one that I've gotten to work correctly so far.
Does any one know the canonical way to achieve this, or a better design pattern?
Thanks in advance!