I am getting this error i don't understand why I have that in my gem file and also included it properly still have no idea how to resolve this error
cannot load such file -- omniauth_oauth
[yahoos_controller]
require 'omniauth_oauth'
require 'multi_json'
module OmniAuth
module Strategies
#
# Authenticate to Yahoo via OAuth and retrieve basic
# user information.
#
# Usage:
#
# use OmniAuth::Strategies::Yahoo, 'consumerkey', 'consumersecret'
#
class YahoosController < omniAuth::strategies::OAuth
def initialize(app, consumer_key, consumer_secret)
super(app, :yahoo, consumer_key, consumer_secret,
# Specifying the full url is the only way yahoo seems to work. Serious WTFery here.
:request_token_url => 'https://api.login.yahoo.com/oauth/v2/get_request_token',
:access_token_url => 'https://api.login.yahoo.com/oauth/v2/get_token',
:authorize_url => "https://api.login.yahoo.com/oauth/v2/request_auth")
end
def auth_hash
ui = user_info
OmniAuth::Utils.deep_merge(super, {
'uid' => ui['uid'],
'user_info' => ui,
'extra' => {'user_hash' => user_hash}
})
end
def user_info
profile = self.user_hash['profile']
nickname = profile['nickname']
{
'uid' => profile['guid'],
'nickname' => nickname,
'name' => profile['givenName'] || nickname,
'image' => profile['image']['imageUrl'],
'description' => profile['message'],
'urls' => {'Profile' => profile['profileUrl'] }
}
end
def user_hash
uid = #access_token.params['xoauth_yahoo_guid']
#user_hash ||= MultiJson.decode(#access_token.get("http://social.yahooapis.com/v1/user/#{uid}/profile?format=json").body)
end
end
end
end
[gem file]
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'mysql2','~> 0.3.20'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'omniauth', '~> 1.2'
gem 'omniauth-auth0', '~> 1.1'
gem 'omniauth-yahoo-oauth2', '~> 1.1'
gem 'nokogiri'
gem 'multi_json', '~> 1.11', '>= 1.11.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
The gem omniauth-auth0 is for authenticating with the auth0 service. You don't appear to want this.
The gem omniauth_oauth is for building generic strategies - you don't need this either.
To authenticate with Yahoo, you should only need these gems:
gem 'omniauth', '~> 1.2'
gem 'omniauth-yahoo-oauth2', '~> 1.1'
To set up Yahoo, it is a simpler set up than the one you are using. It is shown in the docs here. The key part is:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :yahoo_oauth2, yahoo_client_id, yahoo_secret,
name: 'yahoo'
end
Nick
Related
I'm currently trying to deploy my blog using Dokku. I've been following the guides on how to deploy using Dokku, but it wasn't until I got to start deploying the application, I ran into an HTTP Error. I've been using a Mac to develop my blog.
Here's my gem file that I'm using:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
gem "loofah", ">= 2.2.3"
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use Bulma Rails to simply the CSS part of the site
gem "bulma-rails", "~> 0.7.1"
# Using font-awesome to get icons from font-awesome
gem "font-awesome-rails", '~> 4.7', '>= 4.7.0.4'
gem 'font-awesome-sass', '~> 5.5'
# Use Simple for Authentication
gem 'simple_form', '~> 4.0.0'
# FriendlyID
gem 'friendly_id', '~> 5.1.0'
# ACME-CLIENT
gem 'acme-client', '~> 2.0', '>= 2.0.1'
gem 'nokogiri', '~> 1.8', '>= 1.8.5'
gem 'sassc', '~> 1.12', '>= 1.12.1'
# Use ActiveStorage variant
gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Adds likes to comments and blog posts.
gem 'acts_as_votable', '~> 0.11.1'
#Devise - Authnetication Gem
gem 'devise', '~> 4.4', '>= 4.4.3'
#Pundit - Authorization Gem
gem 'pundit', '~> 1.1'
#CKEditor - To make my textarea and blog posts more robust
gem 'ckeditor', '~> 4.2', '>= 4.2.4', github: 'galetahub/ckeditor'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
gem 'carrierwave', '~> 1.0'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Call Rspec to test applications
gem 'rspec-rails', '~> 3.7'
#Factory Bot Rails
gem 'factory_bot_rails', '~> 4.7'
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Use the better errors gem to better locate stack trace errors.
gem "better_errors"
#binding-of-caller
gem 'binding_of_caller', '~> 0.8.0'
# Guard is used to simplify running the server
gem 'guard'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
# Automatically resets the server upon change the view.
gem 'guard-livereload', '~> 2.5', '>= 2.5.2', require: false
gem 'rb-readline'
gem "letter_opener"
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15', '< 4.0'
gem 'selenium-webdriver'
#Database Cleaner - Used to clean the database upon finishing a test.
gem 'database_cleaner'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'pg'
# Require bootstrap
gem 'bootstrap', '~> 4.1.1'
#jQuery for Rails!
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
#Pagination for the site (Note: "kaminari" is Japanese for lightning.)
gem 'kaminari', '~> 1.1', '>= 1.1.1'
I also found some issue that Bundler 2.0.1 doesn't seem to work. If there's else like a code snippet that you may need to solve the issue, please let me know. Thanks.
Edit: Here's my Application Controller
class ApplicationController < ActionController::Base
include Pundit
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
added_attrs = [ :username, :email, :password, :password_confirmation ]
devise_parameter_sanitizer.permit :sign_up, keys: added_attrs
devise_parameter_sanitizer.permit :account_update, keys: added_attrs
devise_parameter_sanitizer.permit :sign_in, keys: added_attrs
end
private
def user_not_authorized
flash[:alert] = "You aren't authorized to go to that page. Contact TheBigL through email at master_biglee#live.ca."
redirect_to (request.referrer || root_path)
end
end
Edit: Here's my config/application.rb file
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Blog
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
end
end
I have a JSON API based on Rails 5. I have a method that brings list of all the products for one particular company, which I want to paginate so that not to bring up all the data at once. For this I came across two gems, namely will_paginate and api-pagination.
After running bundle install and restarting the server, I'm still getting the following error :
NoMethodError (undefined method `paginate' for #<Api::V1::ProductsController:0x007fb25404db30>)
The Products Controller :
require 'roo'
class Api::V1::ProductsController < ApplicationController
respond_to :json
def index
comp_id = params[:company_id]
cat_id = params[:category_id]
if comp_id
if comp_id && cat_id
product = Product.where(:company_id => comp_id, :category_id => cat_id)
else
product = Product.where(:company_id => comp_id)
end
paginate json: product, status: 200
else
render json: { errors: "Company ID is NULL" }, status: 422
end
end
end
Gemfile.rb
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
#Devise Gem for Authentication
gem "devise"
#For JSON Serialization
gem 'active_model_serializers'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'carrierwave'
gem 'roo'
#For Pagination
gem 'will_paginate'
gem 'api-pagination'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
# Use Capistrano for deployment
gem 'capistrano', group: :development
gem 'capistrano-rails', group: :development
gem 'capistrano3-puma', group: :development
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Can someone tell me where I'm going wrong?
Try to make sure your ApplicationController inherits from ActionController::API instead of ActionController::Base. And if for some reason you can't update your controller, you can include the Rails::Pagination module into your ApplicationController manually.
credits
Update:
class ApplicationController
include Rails::Pagination
......
....
end
I have a basic rails app contains nothing but Welcome controller and Index action.Which both empty.I have defined a root route to it.And deployed to heroku.Bu i get "The page you were looking for doesn't exist." this error message.My url is "https://murmuring-island-27368.herokuapp. c o m/".(Please delete the spaces from c o m ).Btw i tried running production env on local but it says "Internal Server Error
Missing secret_token and secret_key_base for 'production' environment, set these values in config/secrets.yml".So what should i do?
This is the gem file.
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
Generate new secret key, Try
rake secret
I can not add gem best_in_place to my table.
class_datatable.rb:
def data
class.map do |record|
[
best_in_place(record, :name),
best_in_place(record, :short_name)
]
end
end
There is an error: NoMethodError (undefined method `best_in_place' for ClassDatatable:0xa9283a44)
My gem file:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'ruby-oci8'
gem 'activerecord-oracle_enhanced-adapter'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-turbolinks'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
#---------------------------------My gems--------------------------------------------------------
#Twitter Bootstrap
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'client_side_validations'
#Datatables
gem 'jquery-datatables-rails', '~> 1.12.2'
gem 'font-awesome-rails' # Icons
gem 'foundation-rails' # zurb foundation
#Best in place
gem 'best_in_place'
#Russian langue
gem 'russian', '~> 0.6.0'
#Jquery UI
gem 'jquery-ui-rails'
#Paginate
gem 'will_paginate'
#-----------------------------------end---------------------------------------------------------
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
Bundle install is done!
If I do like this on the page:
<% Class.all.each do |record| %>
<%= best_in_place(record, :name) %>
<% end %>
That works.
However, the method does not work "def data"
Understood!
It was necessary to add delegate best_in_place section at the beginning of the file class_datatable.rb
For anyone struggling to find the right way to delegate, this is how it is done:
class MyCustomDatatable < AjaxDatatablesRails::Base
# either define them one-by-one
def_delegator :#view, :link_to
def_delegator :#view, :h
def_delegator :#view, :mail_to
# or define them in one pass
def_delegators :#view, :link_to, :h, :mailto, :edit_resource_path, :other_method
# now, you'll have these methods available to be used anywhere
# example: mapping the 2d jsonified array returned.
def data
records.map do |record|
[
link_to(record.fname, edit_resource_path(record)),
mail_to(record.email),
# other attributes
]
end
end
end
Source: https://github.com/antillas21/ajax-datatables-rails#using-view-helpers
In my rails app, activemessaing caused an infinite loop, e.g. when I run bundle install, an error message is given:
"Your Gemfile requires gems that depend on each other, creating an infinite loop. Please remove gem 'activemessaging' and try again."
Any ideas?
Gemfile
source 'https://rubygems.org'
#gem 'dotenv-rails', :groups => [:development, :test]
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'bootstrap-sass', '3.2.0.0'
gem 'rails_config'
gem 'nokogiri-pretty'
gem 'dotenv-rails'
gem 'devise'
gem 'devise_ldap_authenticatable'
gem "activemessaging"
gem 'stomp'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'daemons'
As the message suggests, the problem is caused by the infinite loop dependency, e.g. activemessaging depends on itself. Check the gem spec in activemessaging to see if there is a self dependency defined.
I managed to get it fixed.
Just refer activemessaging to my forked version:
gem "activemessaging", :git => "https://github.com/digital-york/activemessaging.git"
The changes I've made is just to comment out self dependencies in the gem spec.