Ruby-on-rails gem failing for "where" condition of meta_where - ruby-on-rails-3

I have a question about what is probably a gems problem, but may be meta-where. I used gems to install meta_where-1.0.4, and the response was that I succeeded and the uri for meta_where was provided, but when I tried a where-condition in the search method of a controller, similar to this example that meta-where provides:
Person.where(:skill_set.matches => 'Hello%'
an error was reported:
"undefined method 'matches' for :skill_set:Symbol"
It's as if the gem's methods aren't being accessed. I tried using "require" but that didn't help.
I'm using Windows XP, Firefox, Ruby 1.9.2.
What do I need to do?
Thanks, Barney

I assume you have run the migrations and there is a skill_set attribute in the person table: you don't need require. Just add 'gem meta_where' to your Gemfile and then run 'bundle install'.

Related

Sinatra and PostgreSQL - running the entire database and app

I have been struggling with rerunning my apps from MAC OS to my windows OS. I have never liked databases. Anyway, the thing is that I cannot even load up my seeds. It looks like it cannot run the pg gem methods. Here's my error
:in `ensure in run': undefined method `close' for nil:NilClass (NoMethodError)
here's the code the method gets stuck on
require_relative('../models/collection')
require_relative('../models/product')
require('pry')
Product.delete_all()
Collection.delete_all()
fw2015 = Collection.new({
'name' => 'Fall Winter 2015/2016'
})
fw2015.add()
I am pretty sure that it's something with postgres. Thank you for your help
This is a gem issue, not a PostgreSQL issue. It is probably relating to the fact that there are binary portions of the gem and they may not be building right. So you need to make sure that you have the PostgreSQL client libraries and header files installed, and that you have all necessary compilers.
Try uninstalling and re-installing the gem and see what errors and warnings show up.

rvm using /after_cd_bunlder vs --binstubs. How are these different?

How are the outcome of these two methods different? Why use one over the other? I believe they both end up enabling you to issue 'rake' or 'rspec' without the preceeding 'bundle exec". My guess - with method 1 you only have to do this once, and then on ALL new rails project for the rvm ruby version will automatically have the desired feature ( as explained above)?
Method 1:
rvm get head && rvm reload
chmod +x $rvm_path/hooks/after_cd_bundler
bundle install --binstubs
OR
Method 2:
bundle install --binstubs
If found this documentation, but it did not help me understand which method to use. I looked on http://rvm.io and found intergration/bundler and /workflow/hooks.
The is code for after_cd_bundler (but I cannot post anymore links due to stackoverflow.com limitations on me)
This are not two different methods, this is one method and it is described in more detail here: http://robots.thoughtbot.com/post/15346721484/use-bundlers-binstubs
If you are using RVM then you do not need any of this, using --binstubs requires adding to PATH - which is big security risk if used from project directory, RVM comes with rubygems-bundler gem preinstalled which does the automatic loading of bundler (no need for bundle exec), you can find more details about the gem here: https://github.com/mpapis/rubygems-bundler#readme
I am author of rubygems-bundler and maintainer of RVM.

Rails 3.2.11 performance testing issue: Don't know how to build task 'test:benchmark'

I'm following this railscast on performance testing, but I'm immediately running into an issue.
My app is rails 3.2.11, so according to the railscast it should include performance testing, but I don't have a folder called 'test' at all. When I run 'rails generate performance_test homepage' nothing happens or is generated. So I created one manually (to exactly match the railscast source code), but when I run rake test:benchmark I get the error
Don't know how to build task 'test:benchmark'
If I add the 'rails-perftest' gem to my gemfile and run bundle, then again try to generate a performance_test nothing happens, and when I then run rake test:benchmark, it throws a different error of
uninitialized constant Rails::SubTestTask
I've been sure to include the following dependencies in my gem file:
gem 'ruby-prof', group: :test
gem 'test-unit', group: :test
Could anyone help advise me what I'm doing wrong? Thanks!
I am not 100% certain on this, but I am guessing that you might not have your application.rb file configured accordingly. Also check your Gemfile.lock file and run the command bundle install because it could also be something funky going on with your Gems and dependencies.

paper trail gem - undefined local variable or method has_paper_trail

I am using the latest version of paper_trail gem (2.7.1) After the gem installed and table created I have added "has_paper_trail" in my model and end up with getting "undefined local variable or method has_paper_trail". I tried even with lower versions but still getting the same error.
This is a silly mistake as we need to restart the server after gem installation.
Newbies like me often makes such mistakes. Full credit to Thomas for the kind information.

Delayed_job(2.1.4) + Rails(3.0.10) undefined method `delay'

I upgrading a rails application to rails(3.0.10) and update the gem delayed_job. I updated my migration for the table delayed_job but unfortunatly the method ".delay" doesn't work.
NoMethodError: undefined method `delay' for #<User:0x10394d140>
I didn't find a solution for that. I did : "bundle install", I restarted the server, tried to instal as plugin...
Do you have any ideas?
Thanks.
UPDATE :
I fixed the problem but created a file config/initializer/delayed_job.rb with
require 'delayed_job'
Delayed::Worker.backend = :active_record
Sometimes gems just refuse to install properly. I think what you should do is (assuming you have git installed, otherwise go here https://github.com/tobi/delayed_job and download delayed_job as a zip file)
git clone https://github.com/tobi/delayed_job.git
take what he has in his lib folder and put it in yours. wherever you need to use his methods then do
require 'delayed_job'
in the top of those files
I checked this tutorial, it shows a way to setup in rails 3
http://www.dixis.com/?p=335
it suggests using this in your gemfile
gem "delayed_job", :git => 'git://github.com/collectiveidea/delayed_job.git'
(if it doesn't work with this either, then try the same thing that i did, but replace
git clone https://github.com/tobi/delayed_job.git
with
git clone https://github.com/collectiveidea/delayed_job.git
tell me if anything works