Devise_invitable in rails 4? - devise

I am trying to use devise_invitable(0.1.3) in my application and my application already uses devise(3.1.0). I specified the devise_invitable in my gem file and run bundle install it installed successfully but when i run any command it gives the following error:
Error:
uninitialized constant DeviseMailer (NameError)
Can anyone tell what i am doing wrong?
Any help would be appreciated.
Thank You

Per the devise_invitable README, you need to be using the version straight from github if you are on Rails 4:
gem 'devise_invitable', :github => 'scambra/devise_invitable'

Related

Error in Ruby on Rails

I am trying to learn Ruby on rails following the "Agile Web Development with Rails" book.
In the book it says how to create a doc file for your project:
rails_apps> rails new dummy_app
rails_apps> cd dummy_app
dummy_app> rake doc:rails
but I get this error:
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
(See full trace by running task with --trace)
why? and how can i fix it?
You need to install a Javascript runtime. There are a few options listed in the URL in the error message (https://github.com/sstephenson/execjs). If you don't have a strong preference, I'd recommend therubyracer (Google V8).
Just add this to your Gemfile:
gem 'therubyracer', require: "v8"
and run
bundle install

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

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'.

Global access to Rake DSL methods is deprecated

I am working through the Ruby on Rails 3 tutorial book and typed the following on the command line:
rake db:migrate
which produced the following warning.
WARNING: Global access to Rake DSL methods is deprecated. Please Include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method DemoApp::Application#task called at /Users/imac/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
I am not sure what to do about it or how to work with it. I don't know any other command for Rake.
How can I fix this problem?
Adding include Rake::DSL to the Rakefile before the applications load_tasks were called also worked for me.
So in the above user's case before the DemoApp::Application.load_tasks in the Rakefile.
I found this in Stack Overflow question Ruby on Rails and Rake problems: uninitialized constant Rake::DSL. It refers to a #DHH tweet.
Put the following in your Gemfile
gem "rake", "0.8.7"
You may see something like
rake aborted!
You have already activated Rake 0.9.1 ...
I still had a copy of Rake 0.9.1 in my directory so I deleted it.
You can "delete" Rake 0.9.1 by running the following command:
gem uninstall rake -v=0.9.1
If you have multiple versions of the gem installed, you'll be prompted to pick a version.
After 0.9.1 was cleaned out, I ran
bundle update rake
and was finally able to create my database files. I was using rake db:create, but it should work for rake db:migrate as well.
I hope it helps.
I was having the same problem on Windows with the installer. Ruby 1.9.2 and Rails 3.0.9.
Here is what I did:
bundle update rake
bundle show rake
After doing that I was running rake 0.9.2.
Then I updated the Rakefile in application root folder as follows:
require File.expand_path('../config/application', __FILE__)
require 'rake'
# If you named your application something other than SampleApp, change that below
module ::SampleApp
class Application
include Rake::DSL
end
end
module ::RakeFileUtils
extend Rake::FileUtilsExt
end
SampleApp::Application.load_tasks
As noted in the comment, make sure the name of your app is correct in the two appropriate lines above.
If you are seeing this on later versions of Rails (like 3.+) you may also want to verify that your environment is clean by using RVM http://beginrescueend.com/ and creating a specific ruby & gemset for your projects.
Use an .rvmrc file on a per-project basis, this will guarantee you aren't getting older system gems into your projects. Which has bitten me before.
This prevents having to monkey around with generated Rakefiles & such.
bundle exec rake db:migrate will solve your ruby version issues

Prologue with Ruby on Rails 3

I'm a total newbie to RoR and am trying to get the Prologue gem up and running. I've downloaded the prologue zip file from github.com/quickleft/prologue and am trying to follow the instructions in the associated readme file. I have encountered a number of issues....
Q1: What do I actually do with the extracted zip file? For instance, am I supposed to place the extracted files inside specific rails application directories or what ?
I've been able to install the gem by executing "gem install prologue". However, I cannot create a new application using the "prologue new my_app" command - the following message is displayed at the command prompt when I execute that command:
*C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in ``
': No such file or directory - git config --global user.name (Errno::ENOENT)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in `git_user_name'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:33:in new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22 :inrun'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in dispatch'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:38
9:instart'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/bin/prologue:4: in <top (required)>'
from C:/Ruby192/bin/prologue:19:inload'
from C:/Ruby192/bin/prologue:19:in `'*
Q2: Does anyone have any advice on how to overcome this problem?
Q3: Also, when attempting to get prologue up and running is it possible to do this without integrating it into an existing rails application? If so, how?
(I have ruby 1.9.2 and rails 3.0.0 installed on a Windows Vista machine)
Advice/feedback on the above issues would be greatly welcome!
It seems that Prologue needs 'thor', another gem. You can install all dependencies with the command 'bundle install'.
You can integrate Prologue in a new Rails app, but you definitely need some (existing or new) Rails app to run it.

Rails 3 Initializers: No such file to load

I am trying to use the Sunlight API gem with a Rails project. I have installed the gem and can successfully use it from irb.
However, when I put the require statement (require 'sunlight') in sunlight.rb in config/initializers, I get the following error:
/opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require': no such file to load -- sunlight (LoadError)
I checked the permissions on the gems directory, and it is world readable/executable.
Here is the code from sunlight.rb:
require 'rubygems'
require 'sunlight'
Sunlight::Base.api_key = 'bb7b775755054c54aa9715d202f6785c'
Can anyone tell me how to fix this? TIA!
Is sunlight listed in your Gemfile? Rails3 uses Bundler to manage Gem installations.