gem

Creating a gem using Jruby and not Ruby

家住魔仙堡 提交于 2019-12-25 04:15:24
问题 So I was successful in writing a jruby file and reading from a jar file. I also created a seperate Ruby gem, installed it and used it successfully. I would like to write a gem using Jruby (and not ruby). When I did try to do so and after installing the gem, it gave me the following error: `require': cannot load such file -- java (LoadError) Is there a specific way to write a gem using jruby that is different from the way to write a gem usig ruby? If so, please direct me to a useful tutorial

how do I blacklist users slugs with friendly id?

痴心易碎 提交于 2019-12-25 03:13:39
问题 I want to use friendly id so that users can have a nice url. However I want to blacklist certain names such as api or admin or curse words. Where do I load the yaml file to do that? in the model? 回答1: Give the following code a try- class MyModel < ActiveRecord::Base extend FriendlyId excluded_words = ["admin", "api"] friendly_id_config.reserved_words.concat(excluded_words) friendly_id :name, use: [:slugged, :finders] end 回答2: def check_slug_blacklist blacklist = YAML.load_file(Rails.root.join

How to get individual tumblr post's likes count for tumblr_client gem

二次信任 提交于 2019-12-25 03:03:27
问题 I am trying to get likes count for inidividual tumblr posts. I can only seem to get the total likes of the user and also reblog/note_count. Refer to code below. user = Authentication.where(user_id: current_user.id, provider: "tumblr").first oauth_id = user.uid oauth_access_token = user.token oauth_password = user.token_secret client = Tumblr::Client.new(:client => :httpclient) mytumblr = client.posts("testing.tumblr.com", :limit => 10) mytumblr["posts"].each do |posts| p posts["id"] p posts[

Getting Sinatra running on Ubuntu, Uninitialized constant error

六眼飞鱼酱① 提交于 2019-12-25 02:53:34
问题 Trying to get Sinatra setup on Ubuntu 12.04. I have RVM installed, and I think I have installed all dependencies (listed below). I found another SO post (here) that indicated I don't have libssl-dev installed, but it looks like I do. When I run: sudo gem install sinatra I get: ERROR: While executing gem ... (NameError) uninitialized constant Gem::RemoteFetcher::OpenSSL rvm req installs: sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev

Kaminari Ajax paginate doesn't work

吃可爱长大的小学妹 提交于 2019-12-25 02:48:30
问题 I have below view and controller. Though remote: true is mentioned, kaminari calls my method using http (using page refresh). Is there anything i am missing to make my kaminari links ajaxable . In VIEWS: <div id="paginate"> <%= paginate @user, params: {slug: nil, pgsz: 20}, remote: true %> </div> In Controller: @user = Kaminari.paginate_array(@properties, total_count: @search_result.total_count).page(params[:page]).per(params[:pgsz] ||= 20) I will be responding to ajax in my controller, but

how to initialise a rails gem which add associations to models specified by user

醉酒当歌 提交于 2019-12-25 02:21:22
问题 I am in the process of creating a gem which needs to add associations to some models defined by the user. I have an initialiser file which can be copied into the app by a rails generator command and this is where the user will specify the models to add the associations to. BloggyGem.setup do |config| config.user = User config.post = Post end Inside the Gem, I have this specified opts = BloggyGem.settings opts.user.has_many opts.post.to_s.downcase.pluralize.to_sym, :class_name => opts.post

Sinatra Gem Won't Install

我们两清 提交于 2019-12-25 02:19:40
问题 I am running Ubuntu 10.04 on a linode trying to get sinatra, passenger, nginx, and rvm to all play nice with Ruby 1.9.2. I'm running into an issue with gems though: ~/.rvm/gems/ruby-1.9.2-p290/gems$ ls returns daemon_controller-0.2.6 fastthread-1.0.7 passenger-3.0.9 rack-1.3.2 rake-0.9.2 and gem list returns *** LOCAL GEMS *** rack (1.3.2) rake (0.9.2) sinatra (1.2.6) tilt (1.3.3) What is odd to me is that they aren't the same. And sinatra is missing from the .rvm gems. When I go to my

Rails 3.1.1 deploy to Heroku failing

送分小仙女□ 提交于 2019-12-25 01:48:24
问题 After upgrading my Rails 3.0.9 app to 3.1.1, I'm getting the following bundler error when pushing to Heroku-cedar stack: -----> Heroku receiving push -----> Ruby/Rails app detected -----> Installing dependencies using Bundler version 1.1.rc Running: bundle install --without development:test --path vendor/bundle Updating git://github.com/sferik/rails_admin.git Fetching gem metadata from http://rubygems.org/........ Bundler could not find compatible versions for gem "rails": In Gemfile: rails

Rails 4 postgres bug - cannot create database because the pg gem “is missing”, but it is not

痴心易碎 提交于 2019-12-25 01:35:49
问题 I use rails edge (4.0) and when executing: bundle exec rake db:create I get Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile. I do have "gem pg" in my Gemfile and I have run bundle install... what could be the reason for this? thank you 回答1: The problem was that I was using an old version of pg gem (0.9.0), newer versions work as expected! 回答2: For me, works without user/pass, and using host settings on config/database.yml defatul:

Updating ruby version with Rbenv but gems apparently not updated

强颜欢笑 提交于 2019-12-24 19:26:25
问题 I have just updated Ruby from version 1.9.3-p448 to 1.9.3-p484 using rbenv on a Ubuntu Production server. The updating seems to be successful. Ruby version shows the latest version I just updated. However when I look at the gems for this version 1.9.3-p484 under the directory: .rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems . I only find a few gems in that directory. And when I looked at the directory of the previous version, there is a whole bunch of gems in there. Did I miss a step